static-if cant compile

Clayton via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 19 05:17:02 PDT 2015


Pardon me for trivial question, Am new to D.


Why would a statement as below fail to compile. The plan is to do 
some computation at compile-time hence considering the static-if 
statement which fails to compile. The regular  if-statement 
compiles but is not useful since it is a runtime construct.

The error message I get is :  Error: variable i cannot be read at 
compile time




foreach( i; 0..size-1){
		static if  ( i == -1 ){
			//Do something
		}

	}


More information about the Digitalmars-d-learn mailing list