Anonymous function syntax

Jacob Carlborg doob at me.com
Fri Sep 23 01:22:16 PDT 2011


On 2011-09-23 09:34, Walter Bright wrote:
> 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.

I guess so.

> 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?

Maybe, but so could not using the returned value as well.

It sounds so easy in my head.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list