digitalmars.D.learn - 'with(Foo):' not allowed, why?
- Timothee Cour via Digitalmars-d-learn (4/4) Aug 06 2014 Is there a reason why 'with(Foo):' is not allowed, and we have to
- timotheecour (3/9) Aug 08 2014 ping, anyone?
- "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> (5/14) Aug 09 2014 Probably for syntactic reasons: `with` is a statement, while
- "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> (6/21) Aug 09 2014 It's surprisingly easy to implement:
- Messenger (13/28) Aug 09 2014 Also a way to cancel such...
- Fgr (12/42) Aug 09 2014 with(x):
- Era Scarecrow (3/3) Aug 10 2014 I've given my thoughts on the D section. It would be heavily
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)
Aug 06 2014
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?
Aug 08 2014
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: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.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?
Aug 09 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:It's surprisingly easy to implement: https://github.com/schuetzm/dmd/commit/b11368be183fd9b299508722cf8e9c32df2f1ac5 If you think it's useful, you can suggest it on digitalmars.D. If it is well-received, I can add some tests and update the documentation.On Wednesday, 6 August 2014 at 17:03:23 UTC, Timothee Cour via Digitalmars-d-learn wrote: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.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?
Aug 09 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:Also a way to cancel such... struct Foo { nogc: void bar() { with (someEnum): // ... !:with (someEnum) // ? // ... } !: nogc // ? void gcFunction() { /*...*/ } }On Wednesday, 6 August 2014 at 17:03:23 UTC, Timothee Cour via Digitalmars-d-learn wrote: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.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?
Aug 09 2014
On Saturday, 9 August 2014 at 09:52:02 UTC, Messenger wrote:On Saturday, 9 August 2014 at 09:11:53 UTC, Marc Schütz wrote:with(x): without(x); // cancel without(); // cancel following with() declarations order. with(x): with(y): with(z): without()// no more z without(x) // no more x without() // only one remaining so no more y But isn't the with expression considered as a bad practice (whatever the lang. is) ?On Saturday, 9 August 2014 at 03:46:05 UTC, timotheecour wrote:Also a way to cancel such... struct Foo { nogc: void bar() { with (someEnum): // ... !:with (someEnum) // ? // ... } !: nogc // ? void gcFunction() { /*...*/ } }On Wednesday, 6 August 2014 at 17:03:23 UTC, Timothee Cour via Digitalmars-d-learn wrote: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.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?
Aug 09 2014
I've given my thoughts on the D section. It would be heavily useful as a shorthand for enums you plan on using a lot in a switch case or something, beyond that it could be troublesome...
Aug 10 2014