Custom Blocks

Jacob Carlborg doob at me.com
Tue Aug 10 03:01:10 PDT 2010


On 2010-08-10 05:21, Andrei Alexandrescu wrote:
> Chris Williams wrote:
>> I'm not sure whether the design of D 2.0 has stabilized as yet, but if
>> not,
>> I would like to suggest the ability to create custom block types.
> [snip]
>
> FWIW we've been talking a long time ago about a simple lowering - if the
> last argument to a function is a delegate, allow moving the delegate's
> body outside of the function:
>
> fun(a, b, c) { body }
>
> |
> V
>
> fun((a, b, c) { body });
>
> As far as Walter and I could tell, there are no syntactical issues
> created by such a lowering. But we've been wrong about that in the past
> (me 10x more often than him).
>
>
> Andrei

This would be awesome. I think Ruby and Scala have one of the best 
syntax for code blocks/delegates. Until then we can use this somewhat 
ugly hack:

fun(a, b, c) in {
// body
};

For the above to work "fun" should return a struct which implements the 
opIn method.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list