Math functions in expr can be coded in Tcl ========================================== Rev 0.11: No longer need to specify arg count Rev 0.10: Initial release This is an adaption of the "intfun" and "doublefun" extension, written by Donal K. Fellows to define arbitrary math functions for use in expr: http://www.cs.man.ac.uk/~fellows/tcl/funcproc.c This code uses a single "mathf" command, with the return type specified as one of the arguments, and it allows passing a "curried" proc. But most importantly, this now uses the Tcl_Obj* API which is much faster. Here is an example: proc multiple {a b} { return [expr {$a * $b}] } mathf inch2cm double multiple 2.54 puts "1 foot = [expr {inch2cm(12)}] cm" There is one catch: the call to custom math functions cannot be used at global level, because the bytecode compiler will compile expr before the mathf command has actually created the function definition. But if placed inside a proc, everything should be fine.