== 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
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)
*I mean construction via field-by-field assignment. (I made the same
typo in the bug report, lol).
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.
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
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
... or does enumerations only support constant-expressions? Thanks!
Yep, enum is a compile-time thing.
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
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-