curry command
% proc add {a b} {puts "([info level]) $a + $b = [expr {$a + $b}]"} % add 1 2 (1) 1 + 2 = 3 % proc add2 {b} {add 2 $b} % add2 6 (2) 2 + 6 = 8 % set add2 [curry add 2] <feather::curried 0x20031228> % $add2 6 (1) 2 + 6 = 8
Curried objects can themselves be curried although this does not cause them to get any 'hotter' because special code looks for this situation and flattens the two objects together rather than nest them.
The advantage of using curried objects over a named proc is that no extra call frames are introduced so commands like [upvar], [uplevel] and [info level] work the same whether or not the containing proc is curried.
(Apologies for the curry pun. 'hotter' implies that it is less efficient and generates more heat.)
Uses
Curried objects are very useful for callbacks and object oriented code, especially when used in conjunction with lambda functions Feather LambdaObj.
RS: Doesn't
interp alias {} add2 {} add 2
do pretty much the same job out of the box? From the curry syntax above, that command would equally allow constant arguments only left of the variable arguments, i.e. right after the command name. See also Custom curry.