feature request: with(var decl) {}

deadalnix deadalnix at gmail.com
Mon Jul 23 08:38:54 PDT 2012


Le 23/07/2012 16:46, FeepingCreature a écrit :
> On 07/23/12 16:37, Adam D. Ruppe wrote:
>> But it didn't work. It is with(symbol) or with(expression)
>> in the spec.
>>
>>
>>
>> Would it work to also allow with(decl)? It seems to me that
>> it should be ok... kinda similar to the currently allowed
>>
>> if(auto a = foo()) { /* use a here */ }
>>
>>
>> So we're just extending that same idea out to the with statement
>> too.
>
> The more general form would be to make variable declaration an expression. I'm not sure if that causes any ambiguity, parsing-wise, but it allows other neat things as well, like while(vardecl) and if (decl1&&  condition).

With the current grammar, it is difficult, because declarations are 
statements.


More information about the Digitalmars-d mailing list