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

( Documented at ; Download from )

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.