Skip to main content

NOFOLD

[name := ] NOFOLD( expression )

nameOptional. The identifier for this function.
expressionThe expression to evaluate.

The NOFOLD function creates a barrier that prevents optimizations occurring between the expression and the context it is used in. This is used to prevent constant-folding in the context so that it may be evaluated as-is. Note that this does not prevent constant-folding within the expression itself. It is normally only used to prevent test cases being optimized into something completely different, or to temporarily work around bugs in the compiler.

Example:

OUTPUT(2 * 2);  // is normally constant folded to:
OUTPUT(4);      // at compile time. 

  //However adding NOFOLD() around one argument prevents that 
OUTPUT(NOFOLD(2) * 2);

  //Adding NOFOLD() around the entire expression does NOT
  // prevent folding within the argument:
OUTPUT(NOFOLD(2 * 2));
  //is the same as
OUTPUT(NOFOLD(4));