Anonymous function syntax

Walter Bright newshound2 at digitalmars.com
Fri Sep 23 00:34:02 PDT 2011


On 9/22/2011 11:55 PM, Jacob Carlborg wrote:
> On 2011-09-23 08:42, Daniel Murphy wrote:
>> void delegate () foo = { bar(); };
>
> Why can't the compiler do something similar automatically. Then we won't have
> the problem if a lambda returns void or a value.


1. This can get arbitrarily expensive if there are parameters involved (temps 
have to be constructed, copied, & destroyed) and those costs will be hidden.

2. At some point, heroic efforts to coerce one type to another will subvert the 
point of a type system. After all, if the designer of bar() intended the return 
value to be the point, wouldn't such a conversion hide a bug?



More information about the Digitalmars-d mailing list