2 ms·
It is pretty true. There are not many rules in Tcl. One of them is that the first word is a procedure, and the following words are arguments. Procedures are de
by Uhhrrr 7y ago
It is pretty true. There are not many rules in Tcl. One of them is that the first word is a procedure, and the following words are arguments.
Procedures are defined using "proc", which is also a procedure:
proc sum {x y} {
return [expr $x + $y]
}
Here proc is taking 3 args: name, args, and body (curly braces wind up enclosing one arg).
But you can also redefine proc, using proc. Here is a neat function which uses this to keep other procs from being given new definitions:
rename proc _proc
_proc proc {name args body} {
if {[info commands $name]!=""} {
puts stderr "warning: [info script] redefines $name"
}
_proc $name $args $body
}
The above is taken from here: https://wiki.tcl-lang.org/page/Guarded+proc https://wiki.tcl-lang.org/page/Guarded+proc
List of overloaded procs here: https://wiki.tcl-lang.org/page/Overloading+Proc https://wiki.tcl-lang.org/page/Overloading+Proc