--- Comment #1 from Don <> 2010-01-03 14:30:41 PST ---
Created an attachment (id=542)
Patch against DMD2 svn 324

Here is a patch which adds __ctfe as a 'magic variable'. It's a bool which is
true if evaluated in a function at compile-time, but false at run-time.
If evaluated outside a function, it gives a "non-constant expression" error.

Simple example:
import std.stdio;

int foo() {
  if (__ctfe) return 3;  
  writefln("run-time evaluated");
  return 2;

static assert(foo()==3);

void main()

The back-end throws out the if(__ctfe){...} part (even without optimisations
turned on), so there is no runtime penalty for adding if(__ctfe) clauses.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to