| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
December 31, 2016 Reducing visual clutter. | ||||
|---|---|---|---|---|
| ||||
so I have
```
struct Pipeline
{
// some fields.
ref typeof(this) invoke(alias kernel)(TransformArgsOf!kernel args)
{
//...
return this;
}
}
```
and it will be used like
```
void fun1(int a) {}
void fun2(double b) {}
void funn(ulong c) {}
//...
auto pipe = Pipeline(...);
pipe.invoke!fun1(42)
.invoke!fun2(3.14)
.invoke!funn(1u)
//...
;
```
is there anyway to reduce the visual noise of the `invoke`?
I was thinking of trying to (ab)use opDispatch + mixins that returns a callable whose opCall returns the Pipeline by ref. I'm not sure how well that would go given I need `kernel.mangleof`, `typeof(kernel)` and `Parameters!kernel`.
Is there a nicer way to achieve this? Or is this shenanigans not worth it?
| ||||
December 31, 2016 Re: Reducing visual clutter. | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Nicholas Wilson | On Saturday, 31 December 2016 at 11:39:39 UTC, Nicholas Wilson wrote:
> [...]
Oh and `kernel` could be a template function that would need its args forwarded to it.
| |||
December 31, 2016 Re: Reducing visual clutter. | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Nicholas Wilson | On Saturday, 31 December 2016 at 12:31:07 UTC, Nicholas Wilson wrote:
> On Saturday, 31 December 2016 at 11:39:39 UTC, Nicholas Wilson wrote:
>> [...]
>
> Oh and `kernel` could be a template function that would need its args forwarded to it.
Alias it away using a wrapper?
| |||
January 01, 2017 Re: Reducing visual clutter. | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Nicholas Wilson | On Saturday, 31 December 2016 at 12:31:07 UTC, Nicholas Wilson wrote:
> On Saturday, 31 December 2016 at 11:39:39 UTC, Nicholas Wilson wrote:
>> [...]
>
> Oh and `kernel` could be a template function that would need its args forwarded to it.
It's worse than that `kernel` could be a qualified name which would require the opDispatch shenanigans to attempt to recreate piece-by-piece the QN with successive opDispatch's. Urgh.
As much as I don't want to, C++ style opBinary!"<<" is looking the cleanest.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply