What is the corect behavour for lazy in foreach variadic template

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Sep 25 08:47:29 PDT 2015


On 09/25/2015 05:56 AM, Sean Campbell wrote:
> Take the following code for example
>
> module test;
> import std.stdio;
>
> void test(T...)(lazy T args)

I don't think that syntax is implemented. It looks valid to me though. 
There are many qualifier combinations that the compiler is silent about. 
I think this is one of those cases.

Are you familiar with the 'Lazy variadic functions' feature? It works 
but as far as I understand it, all arguments must be of the same type:

   http://dlang.org/function.html

As long as all 'int's are acceptable, the change to your code would be

   void test(int delegate()[] args...)

There is the following related discussion:

   http://forum.dlang.org/post/ppcnyjpzcfptkoxkdrtk@forum.dlang.org

I haven't tried it from but John Colvin's solution there probably has 
the same issue.

Perhaps we need an enhancement that either works in your original code 
or lazy variadics to support something like the following:

   void test(T...)(T delegate()[] args...)

Ali



More information about the Digitalmars-d-learn mailing list