www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - order of declaration/definition

reply "John Colvin" <john.loughran.colvin gmail.com> writes:
enum A = 1;
enum B = C; //Error
static if(A)
     enum C = 0;
enum D = C; //OK

Is order supposed to matter here?
Aug 23 2015
next sibling parent "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> writes:
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.
Aug 24 2015
prev sibling parent reply "vitus" <vitus vitus.vitus> writes:
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.
Aug 27 2015
parent reply Daniel =?UTF-8?B?S296w6Fr?= via Digitalmars-d-learn writes:
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
Aug 27 2015
parent reply "vitus" <vitus vitus.vitus> writes:
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 :)
Aug 27 2015
parent Daniel =?UTF-8?B?S296w6Fr?= via Digitalmars-d-learn writes:
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 ;-)
Aug 27 2015