Often when reading about Tcl (e.g. http://antirez.com/articoli/tclmisunderstood.html) you read that "everything is a command". Sometimes you also hear how other languages are, like Tcl, "command languages."
To me with my background in other languages, I just view these "commands" as statements. What precisely is the difference between a command and a statement?
Traditionally, in Tcl, the phrase "everything is a command" means that there's no such thing as a "reserved word" command, or one that is defined by the system that you can't change. Every single executable piece of Tcl code is of the format:
command ?arg1? ... ?argN?
There's no such thing as a command that's part of the syntax and can't be overwritten (like "if" and other control structures in most languages). It's entirely possible to redefine the "if" command to do something slightly different.
For example, you could redefine "while" as:
proc while {expression body} {
for {} {[uplevel 1 expr $expression]} {} {
uplevel 1 $body
}
}
The above code being untested... but it shows the general idea.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With