proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 10 08:40:28 PDT 2014


On 8/10/14, 1:44 AM, safety0ff wrote:
> On Sunday, 10 August 2014 at 08:34:40 UTC, Era Scarecrow wrote:
>>
>> Depends on how many pesky extra braces you want to avoid...
>>
>> enum Flags {a,b,c,readonly,write,etc}
>>
>> void func(Flags f){
>>   switch(f) {
>>     with(Flags):   //or put this outside the switch...
>
> For that specific case, put it outside the switch and drop the colon:
> http://dpaste.dzfl.pl/f3e78f3265a7

We use this idiom a lot in a project at Facebook. -- Andrei



More information about the Digitalmars-d mailing list