▲ | kazinator a day ago | |||||||
If you treat assignment as a function, then you have to reify environments as run-time objects, whereby you basically lose lexical scope. Lisp originally, as in LISP, had assignment as a function: it was called SET. To use it, you usually had to quote: (SET 'VAR 42). It worked without an environment parameter because variables were in a pervasive environment, but the quote was needed to get the variable symbol as a run-time value. (SET VAR 42) would mean evaluate VAR to a symbol, and then pass that symbol to the SET function along with 42, so whatever variable was in VAR would be assigned. Assignment is inherently non-functional, since it is a side-effect, so it is mostly counterproductive to model it as a function. A pattern matching or logical language can have implicit bindings as the results of an operation, and so produce variables that way. Then instead of assignment you have shadowing, in that some construct binds a variable again that was already used, so that the most recent value then emerges, shadowing the previous one. | ||||||||
▲ | bloaf a day ago | parent [-] | |||||||
So tcl handles it somewhat more elegantly, I think. It also has a set function, but does not require any special quoting because it uses the $ prefix to denote "get the value of this symbol":
and of course because it is modeled as a function (albeit an impure one) you can pass arguments to it as normal:
of course, everything in tcl is a string, so this works too lol
| ||||||||
|