'with(Foo):' not allowed, why?

Messenger via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Aug 9 02:52:01 PDT 2014


On Saturday, 9 August 2014 at 09:11:53 UTC, Marc Schütz wrote:
> On Saturday, 9 August 2014 at 03:46:05 UTC, timotheecour wrote:
>> On Wednesday, 6 August 2014 at 17:03:23 UTC, Timothee Cour via
>> Digitalmars-d-learn wrote:
>>> Is there a reason why 'with(Foo):' is not allowed, and we 
>>> have to
>>> use with(Foo){...} ?
>>> It would be more in line with how other scope definitions 
>>> work (extern(C)
>>> etc)
>>
>> ping, anyone?
>
> Probably for syntactic reasons: `with` is a statement, while 
> `extern(C)`, `@safe`, `private` etc. are attributes.
>
> But the idea is certainly nice, it would only require a simple 
> rewriting rule.

Also a way to cancel such...

   struct Foo {
   @nogc:

     void bar() {
       with (someEnum):
       // ...
       !:with (someEnum)  // ?
       // ...
     }

   !:@nogc  // ?

     void gcFunction() { /*...*/ }
   }


More information about the Digitalmars-d-learn mailing list