Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/tailcall?V=20
QUERY_STRINGV=20
CONTENT_TYPE
DOCUMENT_URI/revision/tailcall
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.69.6.97
REMOTE_PORT26100
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR18.116.118.198
HTTP_CF_RAY87f136a3ac6d606c-ORD
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_ACCEPT*/*
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; [email protected])
HTTP_CF_CONNECTING_IP18.116.118.198
HTTP_CDN_LOOPcloudflare
HTTP_CF_IPCOUNTRYUS

Body


Error

Unknow state transition: LINE -> END

-code

1

-level

0

-errorstack

INNER {returnImm {Unknow state transition: LINE -> END} {}} CALL {my render_wikit tailcall 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\].\n\n\ \ \ \ :\ \ \ '''tailcall'''\ ''command''\ ?''arg''...?\n\n\n\n======\nproc\ fred\ \{\}\ \{\n\ proc\ fred\ \{\}\ \{\n\ \ \ \ \ george\n\ \}\nproc\ george\ \{\}\ \{\n\ proc\ george\ \{\}\ \{\n\ \ \ \ \ \ tailcall\ harry\n\ \}\n\nIf\ I\ call\ fred,\ it's\ almost\ as\ though\ fred\ called\ harry\ directly,\ instead\ of\nIf\ I\ call\ fred,\ it's\ almost\ as\ though\ fred\ called\ harry\ directly,\ instead\ of\ george.\ \ Not\ so?\n\[MS\]:\ \ yup\ -\ all\ traces\ of\ george\ are\ gone\ from\ the\ program\ stack\ when\ harry\ is\n\[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).\nI\ think\ this\ does\ pretty\ much\ what\ delegation\ is\ supposed\ to\ do,\ right?\n\n----\n\n\[jima\]\ (2009-10-15)\ Perhaps\ this\ has\ been\ asked\ before\ or\ somewhere\ else...\n\[jima\]\ 2009-10-15:\ Perhaps\ this\ has\ been\ asked\ before\ or\ somewhere\ else...\n\nI\ mean,\ once\ fred\ knows\ that\ has\ to\ call\ harry\ directly\ the\ bytecodes\ generated\nI\ mean,\ once\ fred\ knows\ that\ has\ to\ call\ harry\ directly\ the\ bytecodes\ generated\ would\ be\ the\ ones\ equivalent\ to\ have\ said:\n======\nproc\ fred\ \{\}\ \{\n\ proc\ fred\ \{\}\ \{\n\ \ \ \ \ harry\n\ \}\n\nI\ reckon\ I\ am\ not\ familiar\ with\ all\ the\ internals\ of\ Tcl\ but\ I\ find\ this\ would\nI\ reckon\ I\ am\ not\ familiar\ with\ all\ the\ internals\ of\ Tcl\ but\ I\ find\ this\ would\ be\ an\ interesting\ thing.\ Wouldn't\ this\ be\ a\ new\ way\ to\ have\ some\ sort\ of\ macros?\n\[MS\]:\ \ Currently,\ `tailcall`\ is\ not\ bytecompiled.\ Everything\ happens\ at\n\[MS\]\ As\ of\ today\ \[tailcall\]\ is\ not\ byte\ compiled,\ everything\ happens\ at\ runtime.\ That\ extremely\ simple\ example\ could\ indeed\ be\ bytecoded\ in\ a\ minute,\ but\ things\ get\ more\ involved\ as\ soon\ as\ \[\[fred\]\]\ has\ a\ bit\ more\ structure\ to\ it:\ arguments,\ local\ variables,\ namespace\ issues\ both\ for\ variable\ and\ command\ lookup,\ multiple\ exit\ points\ with\ different\ (or\ no)\ \[tailcall\]\ in\ them,\ etc.\n\[jima\]:\ Thanks\ a\ lot\ Miguel\ for\ the\ answer.\ I\ see\ the\ point.\ I\ guess\ this\ is\n\[jima\]:\ Thanks\ a\ lot\ Miguel\ for\ the\ answer.\ I\ see\ the\ point.\ I\ guess\ this\ is\ the\ same\ with\ uplevel\ 1,\ isn't\ it?\n======\nproc\ fred\ \{\}\ \{\n\ proc\ fred\ \{\}\ \{\n\ \ uplevel\ 1\ \{\n\ \ \ #code\ here\n\ \ \}\n\ \}\n\nWould\ it\ be\ interesting\ to\ define\ a\ case\ (like\ a\ contract)\ saying\ if\ your\ proc\nWould\ it\ be\ interesting\ to\ define\ a\ case\ (like\ a\ contract)\ saying\ if\ your\ proc\ is\ simple\ enough\ then\ it\ gets\ bytecompiled\ and\ you\ get\ some\ benefits?\n\[MS\]:\ \ you\ do\ not\ mean\ \"bytecompiled\"\ but\ rather\ \"inlined\ into\ the\ caller\",\ as\n\[MS\]\ you\ do\ not\ mean\ \"bytecompiled\"\ but\ rather\ \"inlined\ into\ the\ caller\",\ as\ all\ proc\ bodies\ get\ bytecompiled.\ There\ are\ quite\ a\ few\ other\ issues\ with\ that,\ especially\ to\ accomodate\ Tcl's\ dynamic\ nature.\ Changing\ one\ inlined\ proc\ would\ cause\ a\ spoiling\ of\ all\ bytecodes\ and\ recompilation\ of\ the\ world,\ at\ least\ with\ the\ current\ approach\ to\ bytecode\ lifetime\ management.\ \n----\n\n\[AMG\]:\ Sounds\ a\ lot\ like\ '''exec'''\ in\ \[Unix\ shells\].\ \ See\ \[execline\]\ for\ more\ information\ on\ a\ noninteractive\ Unix\ shell\ where\ everything\ is\ done\ with\ exec/tailcall.\n\[AMG\]:\ Sounds\ a\ lot\ like\ `exec`\ in\ \[Unix\ shells\].\ \ See\ \[execline\]\ for\ more\n----\nSee\ also\ \[TIP\]#\[http://tip.tcl.tk/327%|%327\]\n\n----\n***Interaction\ with\ \[try\]***\n\n===\n'''%'''\ proc\ foo\ \{\}\ \{puts\ \"I'm\ foo\"\}\n'''%'''\ proc\ bar\ \{\}\ \{puts\ \"I'm\ bar\"\;\ try\ \{\ tailcall\ foo\ \}\ finally\ \{\ puts\ \"exitting\"\ \}\}\n''I'm\ foo''\n'''%'''\ bar\n''I'm\ bar''\n''exiting''\n''exitting''\n===\n31-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?\n\[AMG\]:\ \[\[foo\]\]\ is\ invoked\ by\ replacing\ \[\[bar\]\]\ which\ implies\ the\ intervening\ \[\[\[try\]\]\]\ block\ must\ exit\ before\ \[\[foo\]\]\ can\ start.\n\[wdb\]:\ Apparently,\ the\ `tailcall`\ closes\ one\ of\ the\ last\ gaps\ in\n\[wdb\]\ Apparently,\ the\ command\ ''tailcall''\ closes\ one\ of\ the\ last\ gaps\ in\ Tcl:\ Tail\ recursion\ as\ known\ in\ \[Scheme\].\n\n----\n**Emulation**\n\n\[Lars\ H\],\ 2010-05-09:\ As\ of\ late,\ when\ writing\ an\ \[uplevel\],\ I've\ sometimes\ found\ myself\ thinking\ \"That\ would\ be\ slicker\ with\ \[tailcall\],\ but\ I\ can't\ rely\ on\ 8.6\ features\ in\ this\ project\".\ Today\ it\ occurred\ to\ me\ that\ one\ can\ however\ use\ a\ \[proc\]\ to\ emulate\ the\ properties\ of\ \[tailcall\]\ that\ would\ be\ needed\ in\ these\ cases,\ and\ thus\ provide\ a\ route\ for\ forward\ compatibility.\n\nThe\ main\ situation\ I've\ encountered\ is\ that\ of\ delegating\ to\ another\ command\ which\ may\ make\ use\ of\ \[upvar\]\ or\ \[uplevel\].\ That's\ basically\ taken\ care\ of\ by\n\[NEM\]:\ As\ a\ test/demo\ of\ how\ to\ use\ this\ facility,\ here\ is\ a\ simple\ benchmark\nproc\ utailcall\ args\ \{uplevel\ 2\ \$args\}\n\ proc\ utailcall\ \{args\}\ \{uplevel\ 2\ \$args\}\n\nalthough\ it's\ safer\ to\ make\ it\n\n======\nproc\ utailcall\ args\ \{return\ -code\ return\ \[uplevel\ 2\ \$args\]\}\n\ proc\ utailcall\ \{args\}\ \{return\ -code\ return\ \[uplevel\ 2\ \$args\]\}\n\nin\ case\ the\ \"terminate\ proc\ early\"\ aspect\ of\ `tailcall`\ is\ relied\ upon\;\ this\nin\ case\ the\ \"terminate\ proc\ early\"\ aspect\ of\ \[tailcall\]\ is\ relied\ upon\;\ this\ is\ easy\ to\ do\ without\ thinking\ much\ about\ it.\nAnother\ aspect\ of\ `tailcall`\ is\ the\ name\ resolution\ of\ the\ called\ command.\nAnother\ aspect\ of\ \[tailcall\]\ is\ the\ name\ resolution\ of\ the\ called\ command.\ This\ can\ be\ done\ as\ follows\n======\nproc\ ntailcall\ \{cmd\ args\}\ \{\n\ proc\ ntailcall\ \{cmd\ args\}\ \{\n\ \ \ \ \ \ \ \ \[uplevel\ 1\ \[list\ ::namespace\ which\ \$cmd\]\]\ \{*\}\$args\n\ \ \ \ \ \ \ \[uplevel\ 1\ \[list\ ::namespace\ which\ \$cmd\]\]\ \{*\}\$args\n\}\n\ \}\n\nbut\ it's\ almost\ as\ easy\ to\ do\ both\ at\ the\ same\ time\n\n======\nproc\ untailcall\ \{cmd\ args\}\ \{\n\ proc\ untailcall\ \{cmd\ args\}\ \{\n\ \ \ \ \ \ \ \ uplevel\ 2\ \[list\ \[uplevel\ 1\ \[list\ ::namespace\ which\ \$cmd\]\]\]\ \$args\n\ \ \ \ \ \ \ uplevel\ 2\ \[list\ \[uplevel\ 1\ \[list\ ::namespace\ which\ \$cmd\]\]\]\ \$args\n\}\n\ \}\n\nA\ word\ of\ warning\ here\ is\ that\ this\ will\ produce\ a\ very\ confusing\ error\ message\nA\ word\ of\ warning\ here\ is\ that\ this\ will\ produce\ a\ very\ confusing\ error\ message\ if\ the\ command\ is\ undefined,\ as\ \[namespace\ which\]\ returns\ an\ empty\ string\ in\ that\ case.\nA\ third\ aspect\ is\ that\ of\ preserving\ `\[return\]`\ levels.\nA\ third\ aspect\ is\ that\ of\ preserving\ \[return\]\ levels.\n======\nproc\ rtailcall\ args\ \{\n\ proc\ rtailcall\ \{args\}\ \{\n\ \ \ \ dict\ incr\ options\ -level\ 2\n\ \ \ \ return\ -options\ \$options\ \$result\n\}\n\ \}\n\nThis\ leaves\ some\ extra\ material\ in\ the\ \[errorInfo\],\ but\ one\ can\ probably\ live\nThis\ leaves\ some\ extra\ material\ in\ the\ \[errorInfo\],\ but\ one\ can\ probably\ live\ with\ that.\ Combining\ the\ \"r\"\ and\ \"u\"\ aspects\ is\ straightforward,\ but\ will\ leave\ even\ more:\n======\nproc\ rutailcall\ args\ \{\n\ proc\ rutailcall\ \{args\}\ \{\n\ \ \ \ catch\ \{uplevel\ 2\ \$args\}\ result\ options\n\ \ \ \ dict\ incr\ options\ -level\ 2\n\ \ \ \ return\ -options\ \$options\ \$result\n\ \}\n\nTo\ complete\ the\ set,\ one\ might\ just\ as\ well\ write\ down\ the\ combination\ of\ the\nTo\ complete\ the\ set,\ one\ might\ just\ as\ well\ write\ down\ the\ combination\ of\ the\ \"r\"\ and\ \"n\"\ aspects\n======\nproc\ rntailcall\ \{cmd\ args\}\ \{\n\ proc\ rntailcall\ \{args\}\ \{\n\ \ \ \ catch\ \{\n\ \ \ \ \ \ \ \[uplevel\ 1\ \[list\ ::namespace\ which\ \$cmd\]\]\ \{*\}\$args\n\ \ \ \ \}\ result\ options\n\ \ \ \ dict\ incr\ options\ -level\ 2\n\ \ \ \ return\ -options\ \$options\ \$result\n\ \}\n\nand\ of\ all\ three\n\n======\nproc\ rnutailcall\ \{cmd\ args\}\ \{\n\ proc\ rnutailcall\ \{args\}\ \{\n\ \ \ \ catch\ \{\n\ \ \ \ \ \ \ uplevel\ 2\ \[list\ \[uplevel\ 1\ \[list\ ::namespace\ which\ \$cmd\]\]\]\ \$args\n\ \ \ \ \}\ result\ options\n\ \ \ \ dict\ incr\ options\ -level\ 2\n\ \ \ \ return\ -options\ \$options\ \$result\n\ \}\n\nBut\ note:\ ''all\ of\ the\ above\ will\ fail\ if\ used\ for\ tail\ recursion'',\ as\ soon\ as\nBut\ note:\ ''all\ of\ the\ above\ will\ fail\ if\ used\ for\ tail\ recursion'',\ as\ soon\ as\ the\ loops\ get\ long\ enough.\n\n------\n**Replacement\ for\ \[\[\[uplevel\]\]\]**\n\n\[AMG\]:\ \[\[uplevel\]\]\ has\ limitations\ with\ respect\ to\ \[bytecode\]\ compilation\ and\ interpretation\ of\ \[\[\[return\]\]\].\ \ If\ \[\[uplevel\]\]'s\ level\ count\ is\ 1,\ and\ if\ it's\ the\ last\ thing\ being\ done\ in\ the\ \[proc\],\ these\ limitations\ can\ be\ avoided\ by\ using\ \[\[tailcall\]\]\ instead.\ \ Note\ that\ \[\[uplevel\]\]\ takes\ a\ script\ whereas\ \[\[tailcall\]\]\ takes\ a\ command.\ \ If\ you\ want\ to\ pass\ a\ script\ to\ \[\[tailcall\]\],\ make\ it\ be\ the\ sole\ argument\ to\ \[\[\[try\]\]\].\n======\nSee\ original\ discussion\ here:\ \[http://wiki.tcl.tk/1507#pagetocc0434a60\].\ \ Also\ see\ \[http://wiki.tcl.tk/1507#pagetocb7539876\]\ for\ more\ on\ when\ to\ use\ or\ avoid\ \[\[uplevel\]\].\ \ See\ \[http://wiki.tcl.tk/1017#pagetoc74fae1d9\]\ for\ discussion\ and\ performance\ numbers\ regarding\ \[bytecode\]\ compilation\ with\ \[\[\[eval\]\]\],\ \[\[uplevel\]\],\ \[\[try\]\],\ and\ others.\n\n<<categories>>\ Command\ |\ Control\ structure regexp2} CALL {my render tailcall 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\].\n\n\ \ \ \ :\ \ \ '''tailcall'''\ ''command''\ ?''arg''...?\n\n\n\n======\nproc\ fred\ \{\}\ \{\n\ proc\ fred\ \{\}\ \{\n\ \ \ \ \ george\n\ \}\nproc\ george\ \{\}\ \{\n\ proc\ george\ \{\}\ \{\n\ \ \ \ \ \ tailcall\ harry\n\ \}\n\nIf\ I\ call\ fred,\ it's\ almost\ as\ though\ fred\ called\ harry\ directly,\ instead\ of\nIf\ I\ call\ fred,\ it's\ almost\ as\ though\ fred\ called\ harry\ directly,\ instead\ of\ george.\ \ Not\ so?\n\[MS\]:\ \ yup\ -\ all\ traces\ of\ george\ are\ gone\ from\ the\ program\ stack\ when\ harry\ is\n\[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).\nI\ think\ this\ does\ pretty\ much\ what\ delegation\ is\ supposed\ to\ do,\ right?\n\n----\n\n\[jima\]\ (2009-10-15)\ Perhaps\ this\ has\ been\ asked\ before\ or\ somewhere\ else...\n\[jima\]\ 2009-10-15:\ Perhaps\ this\ has\ been\ asked\ before\ or\ somewhere\ else...\n\nI\ mean,\ once\ fred\ knows\ that\ has\ to\ call\ harry\ directly\ the\ bytecodes\ generated\nI\ mean,\ once\ fred\ knows\ that\ has\ to\ call\ harry\ directly\ the\ bytecodes\ generated\ would\ be\ the\ ones\ equivalent\ to\ have\ said:\n======\nproc\ fred\ \{\}\ \{\n\ proc\ fred\ \{\}\ \{\n\ \ \ \ \ harry\n\ \}\n\nI\ reckon\ I\ am\ not\ familiar\ with\ all\ the\ internals\ of\ Tcl\ but\ I\ find\ this\ would\nI\ reckon\ I\ am\ not\ familiar\ with\ all\ the\ internals\ of\ Tcl\ but\ I\ find\ this\ would\ be\ an\ interesting\ thing.\ Wouldn't\ this\ be\ a\ new\ way\ to\ have\ some\ sort\ of\ macros?\n\[MS\]:\ \ Currently,\ `tailcall`\ is\ not\ bytecompiled.\ Everything\ happens\ at\n\[MS\]\ As\ of\ today\ \[tailcall\]\ is\ not\ byte\ compiled,\ everything\ happens\ at\ runtime.\ That\ extremely\ simple\ example\ could\ indeed\ be\ bytecoded\ in\ a\ minute,\ but\ things\ get\ more\ involved\ as\ soon\ as\ \[\[fred\]\]\ has\ a\ bit\ more\ structure\ to\ it:\ arguments,\ local\ variables,\ namespace\ issues\ both\ for\ variable\ and\ command\ lookup,\ multiple\ exit\ points\ with\ different\ (or\ no)\ \[tailcall\]\ in\ them,\ etc.\n\[jima\]:\ Thanks\ a\ lot\ Miguel\ for\ the\ answer.\ I\ see\ the\ point.\ I\ guess\ this\ is\n\[jima\]:\ Thanks\ a\ lot\ Miguel\ for\ the\ answer.\ I\ see\ the\ point.\ I\ guess\ this\ is\ the\ same\ with\ uplevel\ 1,\ isn't\ it?\n======\nproc\ fred\ \{\}\ \{\n\ proc\ fred\ \{\}\ \{\n\ \ uplevel\ 1\ \{\n\ \ \ #code\ here\n\ \ \}\n\ \}\n\nWould\ it\ be\ interesting\ to\ define\ a\ case\ (like\ a\ contract)\ saying\ if\ your\ proc\nWould\ it\ be\ interesting\ to\ define\ a\ case\ (like\ a\ contract)\ saying\ if\ your\ proc\ is\ simple\ enough\ then\ it\ gets\ bytecompiled\ and\ you\ get\ some\ benefits?\n\[MS\]:\ \ you\ do\ not\ mean\ \"bytecompiled\"\ but\ rather\ \"inlined\ into\ the\ caller\",\ as\n\[MS\]\ you\ do\ not\ mean\ \"bytecompiled\"\ but\ rather\ \"inlined\ into\ the\ caller\",\ as\ all\ proc\ bodies\ get\ bytecompiled.\ There\ are\ quite\ a\ few\ other\ issues\ with\ that,\ especially\ to\ accomodate\ Tcl's\ dynamic\ nature.\ Changing\ one\ inlined\ proc\ would\ cause\ a\ spoiling\ of\ all\ bytecodes\ and\ recompilation\ of\ the\ world,\ at\ least\ with\ the\ current\ approach\ to\ bytecode\ lifetime\ management.\ \n----\n\n\[AMG\]:\ Sounds\ a\ lot\ like\ '''exec'''\ in\ \[Unix\ shells\].\ \ See\ \[execline\]\ for\ more\ information\ on\ a\ noninteractive\ Unix\ shell\ where\ everything\ is\ done\ with\ exec/tailcall.\n\[AMG\]:\ Sounds\ a\ lot\ like\ `exec`\ in\ \[Unix\ shells\].\ \ See\ \[execline\]\ for\ more\n----\nSee\ also\ \[TIP\]#\[http://tip.tcl.tk/327%|%327\]\n\n----\n***Interaction\ with\ \[try\]***\n\n===\n'''%'''\ proc\ foo\ \{\}\ \{puts\ \"I'm\ foo\"\}\n'''%'''\ proc\ bar\ \{\}\ \{puts\ \"I'm\ bar\"\;\ try\ \{\ tailcall\ foo\ \}\ finally\ \{\ puts\ \"exitting\"\ \}\}\n''I'm\ foo''\n'''%'''\ bar\n''I'm\ bar''\n''exiting''\n''exitting''\n===\n31-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?\n\[AMG\]:\ \[\[foo\]\]\ is\ invoked\ by\ replacing\ \[\[bar\]\]\ which\ implies\ the\ intervening\ \[\[\[try\]\]\]\ block\ must\ exit\ before\ \[\[foo\]\]\ can\ start.\n\[wdb\]:\ Apparently,\ the\ `tailcall`\ closes\ one\ of\ the\ last\ gaps\ in\n\[wdb\]\ Apparently,\ the\ command\ ''tailcall''\ closes\ one\ of\ the\ last\ gaps\ in\ Tcl:\ Tail\ recursion\ as\ known\ in\ \[Scheme\].\n\n----\n**Emulation**\n\n\[Lars\ H\],\ 2010-05-09:\ As\ of\ late,\ when\ writing\ an\ \[uplevel\],\ I've\ sometimes\ found\ myself\ thinking\ \"That\ would\ be\ slicker\ with\ \[tailcall\],\ but\ I\ can't\ rely\ on\ 8.6\ features\ in\ this\ project\".\ Today\ it\ occurred\ to\ me\ that\ one\ can\ however\ use\ a\ \[proc\]\ to\ emulate\ the\ properties\ of\ \[tailcall\]\ that\ would\ be\ needed\ in\ these\ cases,\ and\ thus\ provide\ a\ route\ for\ forward\ compatibility.\n\nThe\ main\ situation\ I've\ encountered\ is\ that\ of\ delegating\ to\ another\ command\ which\ may\ make\ use\ of\ \[upvar\]\ or\ \[uplevel\].\ That's\ basically\ taken\ care\ of\ by\n\[NEM\]:\ As\ a\ test/demo\ of\ how\ to\ use\ this\ facility,\ here\ is\ a\ simple\ benchmark\nproc\ utailcall\ args\ \{uplevel\ 2\ \$args\}\n\ proc\ utailcall\ \{args\}\ \{uplevel\ 2\ \$args\}\n\nalthough\ it's\ safer\ to\ make\ it\n\n======\nproc\ utailcall\ args\ \{return\ -code\ return\ \[uplevel\ 2\ \$args\]\}\n\ proc\ utailcall\ \{args\}\ \{return\ -code\ return\ \[uplevel\ 2\ \$args\]\}\n\nin\ case\ the\ \"terminate\ proc\ early\"\ aspect\ of\ `tailcall`\ is\ relied\ upon\;\ this\nin\ case\ the\ \"terminate\ proc\ early\"\ aspect\ of\ \[tailcall\]\ is\ relied\ upon\;\ this\ is\ easy\ to\ do\ without\ thinking\ much\ about\ it.\nAnother\ aspect\ of\ `tailcall`\ is\ the\ name\ resolution\ of\ the\ called\ command.\nAnother\ aspect\ of\ \[tailcall\]\ is\ the\ name\ resolution\ of\ the\ called\ command.\ This\ can\ be\ done\ as\ follows\n======\nproc\ ntailcall\ \{cmd\ args\}\ \{\n\ proc\ ntailcall\ \{cmd\ args\}\ \{\n\ \ \ \ \ \ \ \ \[uplevel\ 1\ \[list\ ::namespace\ which\ \$cmd\]\]\ \{*\}\$args\n\ \ \ \ \ \ \ \[uplevel\ 1\ \[list\ ::namespace\ which\ \$cmd\]\]\ \{*\}\$args\n\}\n\ \}\n\nbut\ it's\ almost\ as\ easy\ to\ do\ both\ at\ the\ same\ time\n\n======\nproc\ untailcall\ \{cmd\ args\}\ \{\n\ proc\ untailcall\ \{cmd\ args\}\ \{\n\ \ \ \ \ \ \ \ uplevel\ 2\ \[list\ \[uplevel\ 1\ \[list\ ::namespace\ which\ \$cmd\]\]\]\ \$args\n\ \ \ \ \ \ \ uplevel\ 2\ \[list\ \[uplevel\ 1\ \[list\ ::namespace\ which\ \$cmd\]\]\]\ \$args\n\}\n\ \}\n\nA\ word\ of\ warning\ here\ is\ that\ this\ will\ produce\ a\ very\ confusing\ error\ message\nA\ word\ of\ warning\ here\ is\ that\ this\ will\ produce\ a\ very\ confusing\ error\ message\ if\ the\ command\ is\ undefined,\ as\ \[namespace\ which\]\ returns\ an\ empty\ string\ in\ that\ case.\nA\ third\ aspect\ is\ that\ of\ preserving\ `\[return\]`\ levels.\nA\ third\ aspect\ is\ that\ of\ preserving\ \[return\]\ levels.\n======\nproc\ rtailcall\ args\ \{\n\ proc\ rtailcall\ \{args\}\ \{\n\ \ \ \ dict\ incr\ options\ -level\ 2\n\ \ \ \ return\ -options\ \$options\ \$result\n\}\n\ \}\n\nThis\ leaves\ some\ extra\ material\ in\ the\ \[errorInfo\],\ but\ one\ can\ probably\ live\nThis\ leaves\ some\ extra\ material\ in\ the\ \[errorInfo\],\ but\ one\ can\ probably\ live\ with\ that.\ Combining\ the\ \"r\"\ and\ \"u\"\ aspects\ is\ straightforward,\ but\ will\ leave\ even\ more:\n======\nproc\ rutailcall\ args\ \{\n\ proc\ rutailcall\ \{args\}\ \{\n\ \ \ \ catch\ \{uplevel\ 2\ \$args\}\ result\ options\n\ \ \ \ dict\ incr\ options\ -level\ 2\n\ \ \ \ return\ -options\ \$options\ \$result\n\ \}\n\nTo\ complete\ the\ set,\ one\ might\ just\ as\ well\ write\ down\ the\ combination\ of\ the\nTo\ complete\ the\ set,\ one\ might\ just\ as\ well\ write\ down\ the\ combination\ of\ the\ \"r\"\ and\ \"n\"\ aspects\n======\nproc\ rntailcall\ \{cmd\ args\}\ \{\n\ proc\ rntailcall\ \{args\}\ \{\n\ \ \ \ catch\ \{\n\ \ \ \ \ \ \ \[uplevel\ 1\ \[list\ ::namespace\ which\ \$cmd\]\]\ \{*\}\$args\n\ \ \ \ \}\ result\ options\n\ \ \ \ dict\ incr\ options\ -level\ 2\n\ \ \ \ return\ -options\ \$options\ \$result\n\ \}\n\nand\ of\ all\ three\n\n======\nproc\ rnutailcall\ \{cmd\ args\}\ \{\n\ proc\ rnutailcall\ \{args\}\ \{\n\ \ \ \ catch\ \{\n\ \ \ \ \ \ \ uplevel\ 2\ \[list\ \[uplevel\ 1\ \[list\ ::namespace\ which\ \$cmd\]\]\]\ \$args\n\ \ \ \ \}\ result\ options\n\ \ \ \ dict\ incr\ options\ -level\ 2\n\ \ \ \ return\ -options\ \$options\ \$result\n\ \}\n\nBut\ note:\ ''all\ of\ the\ above\ will\ fail\ if\ used\ for\ tail\ recursion'',\ as\ soon\ as\nBut\ note:\ ''all\ of\ the\ above\ will\ fail\ if\ used\ for\ tail\ recursion'',\ as\ soon\ as\ the\ loops\ get\ long\ enough.\n\n------\n**Replacement\ for\ \[\[\[uplevel\]\]\]**\n\n\[AMG\]:\ \[\[uplevel\]\]\ has\ limitations\ with\ respect\ to\ \[bytecode\]\ compilation\ and\ interpretation\ of\ \[\[\[return\]\]\].\ \ If\ \[\[uplevel\]\]'s\ level\ count\ is\ 1,\ and\ if\ it's\ the\ last\ thing\ being\ done\ in\ the\ \[proc\],\ these\ limitations\ can\ be\ avoided\ by\ using\ \[\[tailcall\]\]\ instead.\ \ Note\ that\ \[\[uplevel\]\]\ takes\ a\ script\ whereas\ \[\[tailcall\]\]\ takes\ a\ command.\ \ If\ you\ want\ to\ pass\ a\ script\ to\ \[\[tailcall\]\],\ make\ it\ be\ the\ sole\ argument\ to\ \[\[\[try\]\]\].\n======\nSee\ original\ discussion\ here:\ \[http://wiki.tcl.tk/1507#pagetocc0434a60\].\ \ Also\ see\ \[http://wiki.tcl.tk/1507#pagetocb7539876\]\ for\ more\ on\ when\ to\ use\ or\ avoid\ \[\[uplevel\]\].\ \ See\ \[http://wiki.tcl.tk/1017#pagetoc74fae1d9\]\ for\ discussion\ and\ performance\ numbers\ regarding\ \[bytecode\]\ compilation\ with\ \[\[\[eval\]\]\],\ \[\[uplevel\]\],\ \[\[try\]\],\ and\ others.\n\n<<categories>>\ Command\ |\ Control\ structure} CALL {my revision tailcall} CALL {::oo::Obj6237162 process revision/tailcall} CALL {::oo::Obj6237160 process}

-errorcode

NONE

-errorinfo

Unknow state transition: LINE -> END
    while executing
"error $msg"
    (class "::Wiki" method "render_wikit" line 6)
    invoked from within
"my render_$default_markup $N $C $mkup_rendering_engine"
    (class "::Wiki" method "render" line 8)
    invoked from within
"my render $name $C"
    (class "::Wiki" method "revision" line 31)
    invoked from within
"my revision $page"
    (class "::Wiki" method "process" line 56)
    invoked from within
"$server process [string trim $uri /]"

-errorline

4