diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-03-03 16:02:25 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-10-15 11:02:49 +1000 |
commit | 8a21e1c0ea44a829f84e526a8302e6effbc4a9b1 (patch) | |
tree | 84f7fe867f2a3adce1a936a5f1e7cdcb724f4cfd /doc/jim_tcl.txt | |
parent | b83beb2febcbe0abcf338e3f915b43889ce93eca (diff) | |
download | jimtcl-8a21e1c0ea44a829f84e526a8302e6effbc4a9b1.zip jimtcl-8a21e1c0ea44a829f84e526a8302e6effbc4a9b1.tar.gz jimtcl-8a21e1c0ea44a829f84e526a8302e6effbc4a9b1.tar.bz2 |
Improvements to tailcall
Add tests and documentation
Make tailcall work within 'try'
Fix tailcall interaction with uplevel
Use tailcall for dispatch in tree.tcl
Also some related improvements in tree.tcl
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'doc/jim_tcl.txt')
-rw-r--r-- | doc/jim_tcl.txt | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/doc/jim_tcl.txt b/doc/jim_tcl.txt index 9c17aa7..c826221 100644 --- a/doc/jim_tcl.txt +++ b/doc/jim_tcl.txt @@ -52,9 +52,10 @@ The major differences are: 15. Must better error reporting. 'info stacktrace' as a replacement for 'errorInfo', 'errorCode' 16. Support for "static" variables in procedures 17. Significantly faster for many scripts/operations -18. Command pipelines via open "|..." are not supported (but see 'exec' and 'socket pipe') -19. Variable traces are not supported -20. The history command is not supported +18. Support for tail-call optimisation, 'tailcall' +19. Command pipelines via open "|..." are not supported (but see 'exec' and 'socket pipe') +20. Variable traces are not supported +21. The history command is not supported CHANGES ------- @@ -3461,6 +3462,27 @@ will return 1, and will return 3. +tailcall +~~~~~~~~ ++*tailcall* 'cmd ?arg...?'+ + +The 'tailcall' command provides an optimised way of invoking a command whilst replacing +the current call frame. This is similar to 'exec' in Bourne Shell. + +The following are identical except the first immediately replaces the current call frame. + + tailcall a b c + + return [uplevel 1 a b c] + +'tailcall' is useful for a dispatch mechanism: + + proc a {cmd args} { + tailcall sub_$cmd {*}$args + } + proc sub_cmd1 ... + proc sub_cmd2 ... + tell ~~~~ +*tell* 'fileId'+ |