D: How to check if a function is chained? a().b().c();

Imperatorn johan_forsberg_86 at hotmail.com
Sat Nov 18 08:26:18 UTC 2023


On Saturday, 18 November 2023 at 07:47:19 UTC, BoQsc wrote:
> Let's say we have a chain of functions.
> ```
>  a().b().c();
> ```
>
>
> I would like to have a behaviour in `a()` that would check if 
> there is `b()` or `c()` chained to it.
>
> If `a();`is not chained: do a `writeln("You forgot to chain 
> this function!");`
>
> #### A function that executes a program
>
> For me syntactically it is important. One real world 
> application would be:
>
> `program("someProgramName").pipe("someOtherProgramName");`
> Executes and pipes output to another program.
>
> `program();` - Only executes the program.

It would be easy if you have some kind of aspect oriented 
framework. Other than that I guess you need to check the trace 
info (or possibly trait).


More information about the Digitalmars-d-learn mailing list