Updated 2013-02-01 04:22:41 by RLE

A C-preprocessor-like macro substitution mechanism for Tcl source code.

( Documented at http://smilax.org/126 ; Download from http://www.smilax.org/126/cmacro.tcl )

Sample Code: Here are three sample macros, "hd", "tl", and "tlN":
 cmacro::define hd X {[lindex X 0]}
 cmacro::define tl X {[lrange X 1 end]}
 cmacro::define tlN {N X} {[lrange X N end]}

Here are two procs (defined with mproc, to expand the macros) that use the above macros:
 cmacro::mproc second list { return hd< tl<$list> > }
 cmacro::mproc tailN {n list} { return tlN<$n, $list> }

Here is what those "mproc" commands actually call to create procs:
 proc second list { return [lindex [lrange $list 1 end] 0] }
 proc tailN {n list} { return [lrange $list $n end] }

See also: macro <-- Notice Sugar and Tmac both do roughly the same thing.