Re: enum with classes/structs

2011-03-11 Thread useo
== Auszug aus Jonathan M Davis (jmdavisp...@gmx.com)'s Artikel > On Thursday, March 10, 2011 11:28:04 bearophile wrote: > > useo: > > > is it possible to declare a enum where all entries are instances of a > > > > > class (or struct), like the following: > > I don't think so. Enums are compile-time

Re: enum with classes/structs

2011-03-10 Thread Jonathan M Davis
On Thursday, March 10, 2011 11:28:04 bearophile wrote: > useo: > > is it possible to declare a enum where all entries are instances of a > > > class (or struct), like the following: > I don't think so. Enums are compile-time constants. > This code doesn't compile: > > class A { >this(uint i)

Re: enum with classes/structs

2011-03-10 Thread Andrej Mitrovic
*I mean construction via field-by-field assignment. (I made the same typo in the bug report, lol).

Re: enum with classes/structs

2011-03-10 Thread Andrej Mitrovic
There's also this bug where the constructor for a struct isn't called: http://d.puremagic.com/issues/show_bug.cgi?id=5460 , and field assignment is not disabled even with the presence of a constructor.

Re: enum with classes/structs

2011-03-10 Thread bearophile
useo: > is it possible to declare a enum where all entries are instances of a > class (or struct), like the following: I don't think so. Enums are compile-time constants. This code doesn't compile: class A { this(uint i) {} } enum myEnum : A { entry1 = new A(0), entry2 = new A(1) } void

Re: enum with classes/structs

2011-03-10 Thread Jonathan M Davis
On Thursday, March 10, 2011 11:15:25 useo wrote: > Hey guys, > > is it possible to declare a enum where all entries are instances of a > class (or struct), like the following: > > class a { >... >public this(uint i) { > ... >} >... > } > > enum myEnum : a { >entry1 = new

Re: enum with classes/structs

2011-03-10 Thread Trass3r
... or does enumerations only support constant-expressions? Thanks! Yep, enum is a compile-time thing.

Re: enum with classes/structs

2011-03-10 Thread Simen kjaeraas
useo wrote: Hey guys, is it possible to declare a enum where all entries are instances of a class (or struct), like the following: class a { ... public this(uint i) { ... } ... } enum myEnum : a { entry1 = new a(0); entry2 = new a(1); } ... or does enumerations only s

enum with classes/structs

2011-03-10 Thread useo
Hey guys, is it possible to declare a enum where all entries are instances of a class (or struct), like the following: class a { ... public this(uint i) { ... } ... } enum myEnum : a { entry1 = new a(0); entry2 = new a(1); } ... or does enumerations only support constant-