Custom control flow statements

Michiel nomail at hotmail.com
Tue Feb 13 10:16:50 PST 2007


> However, any syntactic sugar like this needs to be very carefully
> thought out.  Consider the following:
>
> void a()
> {
>  writefln("starting");
>
>  {
>   scope(exit) writefln("blah");
>  }
> }
>
> This is valid code and there are many times where something like this is
> needed.  Unfortunately, if we implement what you suggest, then the
> second block would get convereted to a delegate and passed as a variadic
> argument to writefln!

I think the semicolon would be in the way. I don't think this syntactic sugar is
in conflict with any existing syntax. You can never create a function with the
name 'scope' or 'for' or 'if', so there's no problem there either.

Or am I missing something?



More information about the Digitalmars-d mailing list