about "with statement"

Ali Çehreli acehreli at yahoo.com
Sun Jun 9 16:48:39 PDT 2013


On 06/09/2013 11:09 AM, deadalnix wrote:

 > On Sunday, 9 June 2013 at 10:22:22 UTC, Jonathan M Davis wrote:

 >> I'd argue that it would make code harder to read, because it hides where
 >> the variables are coming from.

+1. A friend of mine is "still experimenting" with 'with' and I hate 
reading his code. :)

with (new C()) {
     i = 42;    // is that a member of C?
     j = 43;    // how about that?
     foo();     // and that?
     bar();     // and that?
}

Thanks for obfuscating! :)

 > switch(foobar) with(FoobarEnum) {
 >      // ...
 > }
 >
 > That is golden !

+1000 :o)

To me, 'with' is useful only in that case.

Ali



More information about the Digitalmars-d mailing list