On 05/30/2015 11:04 PM, Dennis Ritchie wrote:

> struct Tap(alias func, R)
> {
>      R range;
>
>      alias range this;
>
>      @property auto front()
>      {
>          immutable string myStr = `func(mixin("range.front"));`;
>      immutable string newStr = `mixin(myStr);`;
>      writeln(newStr); // I want them to be printed here `writeln([5]);`
>          mixin(newStr[0 .. $ - 4] ~ `[idx,` ~ newStr[$ - 4 .. $]); // I
> want them to be printed here `[0, 5];`
>          return range.front;
>      }
> }
>
> Is it possible to do using mixins or through any other means? Ie I want
> to catch the moment when `func` is replaced by the invocation of
> `writeln` :)

So, you want to skip that extra func() call and have the code be "inlined". That's one of the things what any decent optimizing compiler does anyway.

I hear great things especially about ldc and that gdc is just good enough. Of course, one needs to check the assembly output to be sure that there is no extra function calls.

Ali

Reply via email to