DMD 0.166 release

Russ Lewis spamhole-2001-07-16 at deming-os.org
Thu Aug 31 18:37:02 PDT 2006


Walter Bright wrote:
> Russ Lewis wrote:
> 
>> Walter Bright wrote:
>>
>>> Russ Lewis wrote:
>>>
>>>> Is there any reason to not use "lazy" as a keyword to modify the
>>>> expression, rather than the parameter?
>>>>
>>>>   void foo(int delegate() dg) {...}
>>>>   void bar(int x,int y) {
>>>>     foo(lazy x+y);
>>>>   }
>>>
>>>
>>> One reason is lazy arguments and non-lazy arguments cannot be passed 
>>> to the same function.
>>
>>
>> One of us is missing something.  I'm not sure who :)  Can you expand 
>> on your response here?
> 
> foo(x + y);
> foo(lazy x + y);
> 
> can't work, because foo needs to know which it is. Just like you can't 
> have the same parameter be both in and out.

Ah, I was wondering if that was what you meant.  What I was suggesting 
was that the code
	lazy x+y
would just be syntax sugar for
	delegate int() { return x+y; }

So, to expand on the previous example:
   void foo(int delegate() dg) {...}
   void foo(int i) {...}
   void bar(int x,int y) {
     foo(lazy x+y); // calls delegate version
     foo(x+y);      // calls int version
   }



More information about the Digitalmars-d-announce mailing list