return [uplevel 1 [list command ?arg ...?]]
This command may not be invoked from within an uplevel into a procedure or inside a catch inside a procedure or lambda.
proc factorial {n {accum 1}} { if {$n < 2} { return $accum } tailcall factorial [expr {$n - 1}] [expr {$accum * $n}] }
Print the elements of a list with alternating lines having different indentations.
proc printList {theList} { if {[llength $theList]} { puts "> [lindex $theList 0]" tailcall printList2 [lrange $theList 1 end] } } proc printList2 {theList} { if {[llength $theList]} { puts "< [lindex $theList 0]" tailcall printList [lrange $theList 1 end] } }
Copyright © 1993 The Regents of the University of California.
Copyright © 1994-1996 Sun Microsystems, Inc.
Licensed under Tcl/Tk terms
https://www.tcl.tk/man/tcl/TclCmd/tailcall.htm