Re: Permitted locations of a version condition

2009-10-30 Thread Stewart Gordon
Rainer Deyke wrote: What makes this case particularly bad is that Walter deliberate chose to limit the power of the 'version' construct in order to prevent overly complex read-only code. Actually, AIUI it's just one of many things he did to eliminate the syntactic fragility that C++ has a lot

Re: Permitted locations of a version condition

2009-10-30 Thread Kagamin
Rainer Deyke Wrote: > - However, the language has other features that can be abused to > provide the functionality in a syntactically ugly way. > - D programmers use these language features to write powerful but ugly > code. There was a word that macros are not needed because string mixins ar

Re: Permitted locations of a version condition

2009-10-30 Thread Rainer Deyke
Phil Deets wrote: > mixin(q"ENUM > enum Tag > { >A, B, > ENUM"~(Version!("symbol")?q"ENUM >C, D, > ENUM":"")~q"ENUM >E, > } > ENUM"); > > That's not pretty, but it's good enough for me; so I'll probably not do > any compiler hacking. "Not pretty" is putting it very lightly. What's ha

Re: Permitted locations of a version condition

2009-10-29 Thread Phil Deets
On Thu, 29 Oct 2009 19:32:56 -0500, Phil Deets wrote: enum Tag { A, B, C, version (5) { D, E, } version (7) { F, G, } // ... } Thanks to Daniel Keep on the learn newsgroup, I got a workaround working. template Version(string symbol) { mixin("version(

Re: Permitted locations of a version condition

2009-10-29 Thread Phil Deets
On Thu, 29 Oct 2009 23:26:39 -0500, Ellery Newcomer wrote: Phil Deets wrote: I put the comma inside the version block because then there wouldn't be duplicate commas if the version was removed. If the version number was 6 in the above example, it would evaluate to "A, B, C, D, E," with my w

Re: Permitted locations of a version condition

2009-10-29 Thread Ellery Newcomer
Phil Deets wrote: > > I put the comma inside the version block because then there wouldn't be > duplicate commas if the version was removed. If the version number was 6 > in the above example, it would evaluate to "A, B, C, D, E," with my way, > but > > enum Tag > { >A, B, C, >version (5)

Re: Permitted locations of a version condition

2009-10-29 Thread Phil Deets
On Thu, 29 Oct 2009 22:16:13 -0500, Stewart Gordon wrote: Phil Deets wrote: I would definitely like the following code to work. enum Tag { A, B, C, version (5) { D, E, } version (7) { F, G, } // ... } So would I, except that it makes more sense to me to have

Re: Permitted locations of a version condition

2009-10-29 Thread Stewart Gordon
Phil Deets wrote: Hello, I looked over the language specification, and I could not find any statement which says where version conditions are permitted. Language syntax is generally left to the BNF blocks dotted around the documentation. I assumed that they would be permitted most places th

Re: Permitted locations of a version condition

2009-10-29 Thread BCS
Hello Phil, On Thu, 29 Oct 2009 19:47:50 -0500, Ellery Newcomer wrote: And the subject has been brought up before (probably more than once). http://www.digitalmars.com/d/archives/digitalmars/D/Conditional_compi lation_inside_asm_and_enum_declarations_93200.html Oops, didn't mean to repeat

Re: Permitted locations of a version condition

2009-10-29 Thread Phil Deets
On Thu, 29 Oct 2009 19:47:50 -0500, Ellery Newcomer wrote: And the subject has been brought up before (probably more than once). http://www.digitalmars.com/d/archives/digitalmars/D/Conditional_compilation_inside_asm_and_enum_declarations_93200.html Oops, didn't mean to repeat past discuss

Re: Permitted locations of a version condition

2009-10-29 Thread Ellery Newcomer
Phil Deets wrote: > Hello, I looked over the language specification, and I could not find > any statement which says where version conditions are permitted. I > assumed that they would be permitted most places that #if would be > reasonable in C, but evidently that is not true as they do not work >