about "with statement"

deadalnix deadalnix at gmail.com
Sun Jun 9 11:09:31 PDT 2013


On Sunday, 9 June 2013 at 10:22:22 UTC, Jonathan M Davis wrote:
> On Sunday, June 09, 2013 12:11:23 khurshid wrote:
>> D language have like Pascal/Delphi  "with statement",  which 
>> very
>> useful for writing readable code.
>> 
>> http://dlang.org/statement.html#WithStatement
>> 
>> Maybe I'm wrong, but, I never saw  where using this statement 
>> in
>> phobos  source codes, what problem using this statement?
>
> I'm not aware of any problems with it, but there's also rarely 
> any reason to
> use it. In most cases, it doesn't really add anything to the 
> code, and I'd
> argue that it would make code harder to read, because it hides 
> where the
> variables are coming from. I don't think that we'd really lose 
> anything if we
> didn't have it, but it's there if you want to use it, and it's 
> not going away.
>
> - Jonathan M Davis

switch(foobar) with(FoobarEnum) {
     // ...
}

That is golden !


More information about the Digitalmars-d mailing list