At any rate, I know what apply is and what apply does (or... I know
what the purpose of apply is in other languages, i.e. languages that
aren't like tcl). It just seems to me that you can get the same
effect in tcl without using apply.
(System32) 55 % apply {x {puts $x}} hi
hi
(System32) 56 % set x puts; $x hi
hi
I always thought languages with apply want the ability to do #2 above,
but of course can't do #2 above. So they have apply which allows this
effect. Tcl can do #2 above, so why need apply? My guess is, apply
is used for other things, or I have a general misnotion of what apply
is.
Thanks.
The key difference between [apply] and variable-first-word is that
[apply] prepares a cosy space named a "call frame", that is a scope
for local variables, including the formal arguments of the lambda,
without any risk of collision with like-names vars of the calling
context; also, [return] within the body works the way you'd think it
does, unlike a [return] in an [eval] of similar intent.
In essence, [apply] creates an unnamed, one-shot proc; this, by the
way, is made rather clear in the apply.n manpage.
-Alex