Version 9 of tailcall

Updated 2009-04-28 13:28:14 by dkf

Like uplevel 1 except that it also causes the current scope to terminate, though the command is looked up in the current context first. Consequence of NRE.

 proc fred {} {
     george
 }

proc george {} {

 proc george {} {
      tailcall harry
 }

If I call fred, it's almost as though fred called harry directly, instead of george. Not so? MS: yup - all traces of george are gone from the program stack when harry is MS yup - all traces of george are gone from the program stack when harry is called. Now, if harry resolves to a different command in george's current namespace than it would under fred's, the harry that is called is george's and not fred's (no diff if the commands are FQ, of course). I think this does pretty much what delegation is supposed to do, right?


AMG: Sounds a lot like exec in Unix shells. AMG: Sounds a lot like exec in Unix shells. See execline for more


See also TIP#327


Interaction with try

% proc foo {} {puts "I'm foo"}
% proc bar {} {puts "I'm bar"; try { tailcall foo } finally { puts "exitting" }}
I'm foo
% bar
I'm bar
exiting
exitting

31-03-2015 HE I'm sure ;-) that I don't understood what happend there. Why "exiting" is printed before "I'm foo" when I call bar?

wdb: Apparently, the tailcall closes one of the last gaps in