Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-11 Thread Walter Bright via Digitalmars-d
On 8/10/2014 6:52 PM, Era Scarecrow wrote: On Monday, 11 August 2014 at 00:23:36 UTC, Walter Bright wrote: I'd suggest simply: private alias FlagStates FS; then use FS.def, etc. The source code has 400 lines (955-1376) where it uses flags of one kind or another. Constantly having to

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-11 Thread Era Scarecrow via Digitalmars-d
On Monday, 11 August 2014 at 06:29:55 UTC, Walter Bright wrote: It's not ideal, but it gets the job done. Keep in mind that you are proposing to use withs to mix up multiple enums with lots of members - name clashes are very possible, and there's no visual clue which enum a name belongs to. It

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-11 Thread Artur Skawina via Digitalmars-d
On 08/10/14 23:01, Era Scarecrow via Digitalmars-d wrote: Does with have to be only for statements? Real example. In my code somewhere i have a large list of enum types that specify a type of formatting and visibility options. [...] Now since i can't use with(): I'm forced to do aliases,

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-11 Thread Era Scarecrow via Digitalmars-d
On Monday, 11 August 2014 at 12:25:52 UTC, Artur Skawina via Digitalmars-d wrote: What you're really looking for is context dependent access to the target scope. That would work for statics and enums, but would probably require a new syntax (it becomes too misleading and/or ambiguous

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Walter Bright via Digitalmars-d
On 8/9/2014 1:04 PM, Timothee Cour via Digitalmars-d wrote: See email: 'with(Foo):' not allowed, why? in 'digitalmars-d-le...@puremagic.com mailto:digitalmars-d-le...@puremagic.com' forum There's already an implementation proposed. No other statement construct works like that, there doesn't

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Brian Schott via Digitalmars-d
On Sunday, 10 August 2014 at 08:12:05 UTC, Walter Bright wrote: On 8/9/2014 1:04 PM, Timothee Cour via Digitalmars-d wrote: See email: 'with(Foo):' not allowed, why? in 'digitalmars-d-le...@puremagic.com mailto:digitalmars-d-le...@puremagic.com' forum There's already an implementation

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Era Scarecrow via Digitalmars-d
On Sunday, 10 August 2014 at 08:12:05 UTC, Walter Bright wrote: On 8/9/2014 1:04 PM, Timothee Cour via Digitalmars-d wrote: See email: 'with(Foo):' not allowed, why? in No other statement construct works like that, there doesn't seem to be much point to adding such a special case. Guess

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Daniel Murphy via Digitalmars-d
Brian Schott wrote in message news:rvypuokvvvoeamryb...@forum.dlang.org... --- static if (true) alias A = B; else: alias A = C; alias D = E; --- 'statement'

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread safety0ff via Digitalmars-d
On Sunday, 10 August 2014 at 08:34:40 UTC, Era Scarecrow wrote: Depends on how many pesky extra braces you want to avoid... enum Flags {a,b,c,readonly,write,etc} void func(Flags f){ switch(f) { with(Flags): //or put this outside the switch... For that specific case, put it outside

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Era Scarecrow via Digitalmars-d
On Sunday, 10 August 2014 at 08:45:00 UTC, safety0ff wrote: For that specific case, put it outside the switch and drop the colon: True, although if you repeat having to work with the type of Foo (or Flags or something) multiple times then the with(): would let you avoid having multiple

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread via Digitalmars-d
On Sunday, 10 August 2014 at 08:12:05 UTC, Walter Bright wrote: On 8/9/2014 1:04 PM, Timothee Cour via Digitalmars-d wrote: See email: 'with(Foo):' not allowed, why? in 'digitalmars-d-le...@puremagic.com mailto:digitalmars-d-le...@puremagic.com' forum There's already an implementation

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Rikki Cattermole via Digitalmars-d
On 10/08/2014 9:34 p.m., Marc Schütz schue...@gmx.net wrote: On Sunday, 10 August 2014 at 08:12:05 UTC, Walter Bright wrote: On 8/9/2014 1:04 PM, Timothee Cour via Digitalmars-d wrote: See email: 'with(Foo):' not allowed, why? in 'digitalmars-d-le...@puremagic.com

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Idan Arye via Digitalmars-d
On Sunday, 10 August 2014 at 08:29:14 UTC, Brian Schott wrote: On Sunday, 10 August 2014 at 08:12:05 UTC, Walter Bright wrote: On 8/9/2014 1:04 PM, Timothee Cour via Digitalmars-d wrote: See email: 'with(Foo):' not allowed, why? in 'digitalmars-d-le...@puremagic.com

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread via Digitalmars-d
On Sunday, 10 August 2014 at 12:34:47 UTC, Idan Arye wrote: On Sunday, 10 August 2014 at 08:29:14 UTC, Brian Schott wrote: On Sunday, 10 August 2014 at 08:12:05 UTC, Walter Bright wrote: On 8/9/2014 1:04 PM, Timothee Cour via Digitalmars-d wrote: See email: 'with(Foo):' not allowed, why? in

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Andrei Alexandrescu via Digitalmars-d
On 8/10/14, 1:44 AM, safety0ff wrote: On Sunday, 10 August 2014 at 08:34:40 UTC, Era Scarecrow wrote: Depends on how many pesky extra braces you want to avoid... enum Flags {a,b,c,readonly,write,etc} void func(Flags f){ switch(f) { with(Flags): //or put this outside the switch...

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Walter Bright via Digitalmars-d
On 8/10/2014 1:29 AM, Brian Schott wrote: On Sunday, 10 August 2014 at 08:12:05 UTC, Walter Bright wrote: No other statement construct works like that, there doesn't seem to be much point to adding such a special case. --- static if (true): alias A = B; --- --- static if (true)

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Walter Bright via Digitalmars-d
On 8/10/2014 2:34 AM, Marc Schütz schue...@gmx.net wrote: It's possible to add this syntax for any statement, The reason for the : syntax for declarations is that modules can be quite long, and it: 1. avoids a lonely } that might be 3000-10,000 lines of code away 2. avoids requiring

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Era Scarecrow via Digitalmars-d
On Sunday, 10 August 2014 at 17:29:24 UTC, Walter Bright wrote: 1. labels 2. case statements 3. default statements 4. ?: expressions and overloading this with more meanings is, in my not-so-humble-opinion, not a good idea given the very marginal benefit it might have. 5. Access

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Timon Gehr via Digitalmars-d
On 08/10/2014 08:34 PM, Era Scarecrow wrote: Although I'm not sure how much it adds for complexity to the compiler (if any). It is a trivial change in the parser.

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Era Scarecrow via Digitalmars-d
On Sunday, 10 August 2014 at 18:56:40 UTC, Timon Gehr wrote: On 08/10/2014 08:34 PM, Era Scarecrow wrote: Although I'm not sure how much it adds for complexity to the compiler (if any). It is a trivial change in the parser. Then I'd say give it a try on a branch and see how it performs

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Walter Bright via Digitalmars-d
On 8/10/2014 11:34 AM, Era Scarecrow wrote: On Sunday, 10 August 2014 at 17:29:24 UTC, Walter Bright wrote: 1. labels 2. case statements 3. default statements 4. ?: expressions and overloading this with more meanings is, in my not-so-humble-opinion, not a good idea given the very marginal

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Era Scarecrow via Digitalmars-d
On Sunday, 10 August 2014 at 20:12:56 UTC, Walter Bright wrote: On 8/10/2014 11:34 AM, Era Scarecrow wrote: 5. Access permissions (public/private/protected). 6. File length attributes (@safe: @system: @trusted:) Again, that is for declarations, not statements. Does with have to be only

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Dicebot via Digitalmars-d
On Saturday, 9 August 2014 at 20:04:13 UTC, Timothee Cour via Digitalmars-d wrote: See email: 'with(Foo):' not allowed, why? in ' digitalmars-d-le...@puremagic.com' forum There's already an implementation proposed. If this is going to be accepted I will most likely resort to DScanner rule

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Era Scarecrow via Digitalmars-d
On Sunday, 10 August 2014 at 23:16:57 UTC, Dicebot wrote: If this is going to be accepted I will most likely resort to DScanner rule that statically prohibits it, don't like such features. Even attribute: syntax can easily result in code obfuscation and should be used with caution - and this

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Dicebot via Digitalmars-d
On Sunday, 10 August 2014 at 23:29:17 UTC, Era Scarecrow wrote: On Sunday, 10 August 2014 at 23:16:57 UTC, Dicebot wrote: If this is going to be accepted I will most likely resort to DScanner rule that statically prohibits it, don't like such features. Even attribute: syntax can easily result

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Walter Bright via Digitalmars-d
On 8/10/2014 2:01 PM, Era Scarecrow wrote: On Sunday, 10 August 2014 at 20:12:56 UTC, Walter Bright wrote: On 8/10/2014 11:34 AM, Era Scarecrow wrote: 5. Access permissions (public/private/protected). 6. File length attributes (@safe: @system: @trusted:) Again, that is for declarations,

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-10 Thread Era Scarecrow via Digitalmars-d
On Monday, 11 August 2014 at 00:23:36 UTC, Walter Bright wrote: I'd suggest simply: private alias FlagStates FS; then use FS.def, etc. The source code has 400 lines (955-1376) where it uses flags of one kind or another. Constantly having to add that type of thing in just fills up space

proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-09 Thread Timothee Cour via Digitalmars-d
See email: 'with(Foo):' not allowed, why? in ' digitalmars-d-le...@puremagic.com' forum There's already an implementation proposed.