Lib/Source/Functions.cpp
/**
 * Create a function snippet from the generation of the passed callback
 *
 * This hijacks the global statement stack to generate from source lang,
 * and then isolates the generation in a separate expression.
 *
 * The immediate benefit of this is to be able to define source lang
 * constructs using the source lang itself.

 * This can be done to some extent directly, but defining them as standalone code
 * is more flexible.
 * The code snippets are relocatable and can be inserted anywhere
 *
 * Potential other uses:
 *   - memoization
 *   - true functions (currently everything generated inline)
 *
 * Because this uses the global statement stack, it is **not** threadsafe.
 * But then again, nothing using the global statement stack is.
 */
Create a function snippet from the generation of the passed callback
This hijacks the global statement stack to generate from source lang,
and then isolates the generation in a separate expression.

The immediate benefit of this is to be able to define source lang
constructs using the source lang itself.

This can be done to some extent directly, but defining them as standalone code
is more flexible.
The code snippets are relocatable and can be inserted anywhere

Potential other uses:
- memoization
- true functions (currently everything generated inline)

Because this uses the global statement stack, it is **not** threadsafe.
But then again, nothing using the global statement stack is.
Create a function snippet from the generation of the passed callback This hijacks the global statement stack to generate from source lang and then isolates the generation in a separate expression . The immediate benefit of this is to be able to define source lang constructs using the source lang itself . This can be done to some extent directly but defining them as standalone code is more flexible . The code snippets are relocatable and can be inserted anywhere Potential other uses : - memoization - true functions ( currently everything generated inline ) Because this uses the global statement stack it is ** not ** threadsafe . But then again nothing using the global statement stack is .
IntExpr create_function_snippet(StackCallback f) {
  auto stmts = tempStmt(f);
  assert(!stmts.empty());
  stmtStack() << stmts;
  Stmt::Ptr ret = stmts.back();
  return ret->assign_rhs();
}
IntExpr create_function_snippet ( StackCallback f ) { auto stmts = tempStmt ( f ) ; assert ( ! stmts . empty ( ) ) ; stmtStack ( ) << stmts ; Stmt :: Ptr ret = stmts . back ( ) ; return ret -> assign_rhs ( ) ; }
Create a function snippet from the generation of the passed callback
 This hijacks the global statement stack to generate from source lang,
 and then isolates the generation in a separate expression.
Create a function snippet from the generation of the passed callback This hijacks the global statement stack to generate from source lang and then isolates the generation in a separate expression .