feature request: with(var decl) {}

FeepingCreature default_357-line at yahoo.de
Mon Jul 23 07:46:29 PDT 2012


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).


More information about the Digitalmars-d mailing list