version in enum

2016-01-09 Thread Øivind via Digitalmars-d-learn
Hi, Why doesn't this work? Seems like it should: enum { A = 1, version(xx) { B = 2 } } void main() { } Compilation output: /d732/f174.d(5): Error: basic type expected, not version /d732/f174.d(5): Error: no identifier for declarator int /d732

Re: version in enum

2016-01-09 Thread Basile B. via Digitalmars-d-learn
On Saturday, 9 January 2016 at 12:43:32 UTC, Øivind wrote: Hi, Why doesn't this work? Seems like it should: enum { A = 1, version(xx) { B = 2 } } It's not allowed in the grammar but I agree with you, it could be useful. Recent example where it could

Re: version in enum

2016-01-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 9 January 2016 at 12:43:32 UTC, Øivind wrote: Why doesn't this work? Seems like it should: D defines version to only work on *complete* blocks. You're trying to use it on a partial block there. You'll have to try something else. Perhaps copying the whole enum in the different

Re: version in enum

2016-01-09 Thread Jonathan M Davis via Digitalmars-d-learn
on a partial block there. > > You'll have to try something else. Perhaps copying the whole enum > in the different version blocks Yeah. That's what we do in core.time.ClockType. You have to duplicate the entire enum for each version with each enum declaration listing exactly which me

Re: version specific enum members

2009-10-30 Thread Phil Deets
On Fri, 30 Oct 2009 06:38:44 -0500, Ary Borenszweig a...@esperanto.org.ar wrote: Phil Deets wrote: On Thu, 29 Oct 2009 18:28:12 -0500, Ary Borenszweig a...@esperanto.org.ar wrote: Ellery Newcomer wrote: Unfortunately, that's going to be about the best you can do, unless you're willing

version specific enum members

2009-10-29 Thread Phil Deets
Hi, is there a way to add members to an enum based on conditional compilation symbols. I tried enum Tag { A, B, version (symbol) { C, D, } E, } but it doesn't work. I know I could do version (symbol) { enum Tag { A, B, C, D, E } } else { enum Tag { A, B, E } } but I

Re: version specific enum members

2009-10-29 Thread Ellery Newcomer
Phil Deets wrote: Hi, is there a way to add members to an enum based on conditional compilation symbols. I tried enum Tag { A, B, version (symbol) { C, D, } E, } but it doesn't work. I know I could do version (symbol) { enum Tag { A, B, C, D, E } } else

Re: version specific enum members

2009-10-29 Thread Ary Borenszweig
Ellery Newcomer wrote: Phil Deets wrote: Hi, is there a way to add members to an enum based on conditional compilation symbols. I tried enum Tag { A, B, version (symbol) { C, D, } E, } but it doesn't work. I know I could do version (symbol) { enum Tag { A, B, C, D, E

Re: version specific enum members

2009-10-29 Thread Phil Deets
, } but it doesn't work. I know I could do version (symbol) { enum Tag { A, B, C, D, E } } else { enum Tag { A, B, E } } but I don't want to do that since in my case, there can be quite a few elements outside of the version, and I don't want to repeat them all. Unfortunately, that's going

Re: version specific enum members

2009-10-29 Thread Daniel Keep
Phil Deets wrote: Hi, is there a way to add members to an enum based on conditional compilation symbols. I tried enum Tag { A, B, version (symbol) { C, D, } E, } but it doesn't work. I know I could do version (symbol) { enum Tag { A, B, C, D, E } } else

Re: version specific enum members

2009-10-29 Thread Phil Deets
know I could do version (symbol) { enum Tag { A, B, C, D, E } } else { enum Tag { A, B, E } } but I don't want to do that since in my case, there can be quite a few elements outside of the version, and I don't want to repeat them all. template Version(char[] ident) { mixin(`version