Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
August 24, 2015 order of declaration/definition | ||||
---|---|---|---|---|
| ||||
enum A = 1; enum B = C; //Error static if(A) enum C = 0; enum D = C; //OK Is order supposed to matter here? |
August 24, 2015 Re: order of declaration/definition | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Colvin | On Monday, 24 August 2015 at 01:01:13 UTC, John Colvin wrote:
> enum A = 1;
> enum B = C; //Error
> static if(A)
> enum C = 0;
> enum D = C; //OK
>
> Is order supposed to matter here?
No.
|
August 27, 2015 Re: order of declaration/definition | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Colvin | On Monday, 24 August 2015 at 01:01:13 UTC, John Colvin wrote:
> enum A = 1;
> enum B = C; //Error
> static if(A)
> enum C = 0;
> enum D = C; //OK
>
> Is order supposed to matter here?
Beter:
enum E = 1;
struct Foo{
enum X1 = E;
static if(1) enum E = 2;
enum X2 = E;
}
static assert(Foo.X1 != Foo.X2);
class Bar{
enum X1 = __traits(isAbstractClass, typeof(this));
static if(1) abstract void bar();
enum X2 = __traits(isAbstractClass, typeof(this));
}
static assert(Bar.X1 != Bar.X2);
mixins has same problem.
|
August 27, 2015 Re: order of declaration/definition | ||||
---|---|---|---|---|
| ||||
Posted in reply to vitus | On Thu, 27 Aug 2015 13:01:02 +0000 vitus via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: > On Monday, 24 August 2015 at 01:01:13 UTC, John Colvin wrote: > > enum A = 1; > > enum B = C; //Error > > static if(A) > > enum C = 0; > > enum D = C; //OK > > > > Is order supposed to matter here? > > Beter: > > enum E = 1; > struct Foo{ > enum X1 = E; > static if(1) enum E = 2; > enum X2 = E; > } > > static assert(Foo.X1 != Foo.X2); > > > class Bar{ > enum X1 = __traits(isAbstractClass, typeof(this)); > static if(1) abstract void bar(); > enum X2 = __traits(isAbstractClass, typeof(this)); > } > > static assert(Bar.X1 != Bar.X2); > > > mixins has same problem. works ok for me |
August 27, 2015 Re: order of declaration/definition | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozák | On Thursday, 27 August 2015 at 13:14:24 UTC, Daniel Kozák wrote:
>
> On Thu, 27 Aug 2015 13:01:02 +0000
> vitus via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:
>>
>
> works ok for me
V tom je ten problém :)
|
August 27, 2015 Re: order of declaration/definition | ||||
---|---|---|---|---|
| ||||
Posted in reply to vitus | On Thu, 27 Aug 2015 13:26:11 +0000 vitus via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote: > On Thursday, 27 August 2015 at 13:14:24 UTC, Daniel Kozák wrote: > > > > On Thu, 27 Aug 2015 13:01:02 +0000 > > vitus via Digitalmars-d-learn > > <digitalmars-d-learn@puremagic.com> wrote: > >> > > > > works ok for me > > V tom je ten problém :) Jo mas pravdu :) po prepsani na: enum E = 1; struct Foo{ enum X1 = E; enum E = 2; enum X2 = E; } static assert(Foo.X1 != Foo.X2); class Bar{ enum X1 = __traits(isAbstractClass, typeof(this)); abstract void bar(); enum X2 = __traits(isAbstractClass, typeof(this)); } static assert(Bar.X1 != Bar.X2); void main() { import std.stdio; writeln(Foo.X1, Foo.X2); writeln(Bar.X1, Bar.X2); } to uz vidim ;-) |
Copyright © 1999-2021 by the D Language Foundation