Tcl has a mechanism that allows you to define aliases for procedures in the interpreter.
If you
proc foo {one two three} {do something with $one $two $three}
and you find that you always pass $ a and $ b as the first two arguments, you can write:
interp alias {} foo_ab {} foo $a $b
And now you can say:
foo_ab $d ;
foo_ab $e ;
Example:
proc foo {one two three} {puts [join [list $one $two $three] :]}
set a Hello
set b World
interp alias {} foo_ab {} foo $a $b
foo_ab example ;
The empty braces in the command interp aliassimply mean the current interpreter. You can do a lot of fun with the help of subordinate translators.
source
share