about "with statement"

2013-06-09 Thread khurshid
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? Regards, Khurshid.

Re: about "with statement"

2013-06-09 Thread Jonathan M Davis
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,

Re: about "with statement"

2013-06-09 Thread bearophile
khurshid: D language have like Pascal/Delphi "with statement", which very useful for writing readable code. It's a quite useful statement, especially with enumerations or associative array literals, to avoid repeating many times their name: switch (en) with (MyEnum) { case foo: ... c

Re: about "with statement"

2013-06-09 Thread mike james
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

Re: about "with statement"

2013-06-09 Thread mike james
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

Re: about "with statement"

2013-06-09 Thread bearophile
mike james: Even Wirth gave up on the "with" statement in his later languages design. I think he was trying to remove all the not essential features from the design of its language, to produce something essential. I prefer a language that has more handy things, even if they are not strictly

Re: about "with statement"

2013-06-09 Thread Andrej Mitrovic
On 6/9/13, bearophile wrote: > It's a quite useful statement, especially with enumerations or > associative array literals, to avoid repeating many times their > name: > > switch (en) with (MyEnum) { >case foo: ... >case bar: ... > } Yep, I use this idiom a lot. It's also very useful in u

Re: about "with statement"

2013-06-09 Thread deadalnix
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

Re: about "with statement"

2013-06-09 Thread Ivan Kazmenko
On Sunday, 9 June 2013 at 11:56:42 UTC, Andrej Mitrovic wrote: There are some bugs with it currently, but I think they're fixable. Currently, "with" does not look into "alias this" members which somewhat limits its usefulness: http://d.puremagic.com/issues/show_bug.cgi?id=6711 http://d.purem

Re: about "with statement"

2013-06-09 Thread khurshid
On Sunday, 9 June 2013 at 11:11:47 UTC, bearophile wrote: khurshid: D language have like Pascal/Delphi "with statement", which very useful for writing readable code. It's a quite useful statement, especially with enumerations or associative array literals, to avoid repeating many times the

Re: about "with statement"

2013-06-09 Thread Nick Sabalausky
On Sun, 09 Jun 2013 20:09:31 +0200 "deadalnix" wrote: > > switch(foobar) with(FoobarEnum) { > // ... > } > > That is golden ! Oooh! That's a good one! I don't think I've ever used "with" in any language before (never saw much point), but I probably will start using that.

Re: about "with statement"

2013-06-09 Thread Idan Arye
On Sunday, 9 June 2013 at 19:03:12 UTC, khurshid wrote: On Sunday, 9 June 2013 at 11:11:47 UTC, bearophile wrote: khurshid: D language have like Pascal/Delphi "with statement", which very useful for writing readable code. It's a quite useful statement, especially with enumerations or asso

Re: about "with statement"

2013-06-09 Thread Ali Çehreli
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

Re: about "with statement"

2013-06-09 Thread Maxim Fomin
On Sunday, 9 June 2013 at 23:48:39 UTC, Ali Çehreli wrote: 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 mi

Re: about "with statement"

2013-06-10 Thread Jacob Carlborg
On 2013-06-09 20:09, deadalnix wrote: switch(foobar) with(FoobarEnum) { // ... } That is golden ! I agree, that's basically the only case I've used "with" for. -- /Jacob Carlborg

Re: about "with statement"

2013-06-10 Thread Marco Leise
Am Sun, 09 Jun 2013 16:48:39 -0700 schrieb Ali Çehreli : > > switch(foobar) with(FoobarEnum) { > > // ... > > } > > > > That is golden ! > > +1000 :o) > > To me, 'with' is useful only in that _case_. Pun intended? I even remember someone being surprised that it had other uses than th

Re: about "with statement"

2013-06-10 Thread Anthony Goins
On Sunday, 9 June 2013 at 10:11:25 UTC, 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

Re: about "with statement"

2013-06-10 Thread Denis Shelomovskij
09.06.2013 14:11, khurshid пишет: 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 state

Re: about "with statement"

2013-06-10 Thread Ali Çehreli
On 06/10/2013 02:43 AM, Marco Leise wrote: > Am Sun, 09 Jun 2013 16:48:39 -0700 > schrieb Ali Çehreli : > >> > switch(foobar) with(FoobarEnum) { >> > // ... >> > } >> To me, 'with' is useful only in that _case_. > > Pun intended? Ha ha! :) No, I missed that one. Ali

Re: about "with statement"

2013-06-10 Thread Steven Schveighoffer
On Sun, 09 Jun 2013 14:09:31 -0400, deadalnix wrote: 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/statemen

Re: about "with statement"

2013-06-10 Thread Nick Sabalausky
On Mon, 10 Jun 2013 15:33:44 +0200 "Anthony Goins" wrote: > > Am I the only one that found this useful? > Is there a better way? > > with (specificModule) > { > result = ufcsChain.ambiguousFunction.link3(); > } Ooh, that's another good one!

Re: about "with statement"

2013-06-10 Thread Baz
On Sunday, 9 June 2013 at 10:11:25 UTC, 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