Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/array?V=135
QUERY_STRINGV=135
CONTENT_TYPE
DOCUMENT_URI/revision/array
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.69.6.70
REMOTE_PORT65458
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR3.133.109.211
HTTP_CF_RAY879f1fb5eb0b60b3-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_IP3.133.109.211
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 array '''`\[http://www.tcl.tk/man/tcl/TclCmd/array.htm%|%array\]`'''\ is\ a\ \[Tcl\ Commands%|%built-in\]\ ensemble\ of\ \[command%|%commands\]\ that\ manipulates\ \[Tcl\]'s\ array\ variables.\ \ Array\ variables\ can\ also\ be\nmanipulated\ using\ \[Dodekalogue%|%''arrayName''(''key'')\]\ syntax.\n\n\n\n**\ Synopsis\ **\n\n\ \ \ \ :\ \ \ '''\[array\ anymore\]'''\ ''arrayName\ searchId''\n\n\ \ \ \ :\ \ \ '''\[array\ donesearch\]'''\ ''arrayName\ searchId''\n\n\ \ \ \ :\ \ \ '''\[array\ exists\]'''\ ''arrayName''\n\n\ \ \ \ :\ \ \ '''\[array\ get\]'''\ ''arrayName\ ''?''pattern''?\n\n\ \ \ \ :\ \ \ '''\[array\ names\]'''\ ''arrayName\ ''?''mode''?\ ?''pattern''?\n\n\ \ \ \ :\ \ \ '''\[array\ nextelement\]'''\ ''arrayName\ searchId''\n\n\ \ \ \ :\ \ \ '''\[array\ set\]'''\ ''arrayName\ list''\n\n\ \ \ \ :\ \ \ '''\[array\ size\]'''\ ''arrayName''\n\n\ \ \ \ :\ \ \ '''\[array\ startsearch\]'''\ ''arrayName''\n\n\ \ \ \ :\ \ \ '''\[array\ statistics\]'''\ ''arrayName''\n\n\ \ \ \ :\ \ \ '''\[array\ unset\]'''\ ''arrayName\ ''?''pattern''?\n\n\n\n**\ Documentation\ **\n\n\ \ \ \[http://www.tcl.tk/man/tcl/TclCmd/array.htm%|%man\ page\]:\ \ \ \n\n\n\n**\ Description\ **\n\nA\ Tcl\ '''array'''\ is\ a\ \[container\]\ of\ variables.\ \ Tcl's\n\[Dodekalogue%|%two-component\]\ `\$''arrayName''(''key'')`\ syntax\ can\ be\ used\ to\n\[variable\ substitution%|%substitute\]\ individual\ values\ of\ an\ array.\ \ The\ name\nof\ a\ variable\ in\ an\ array\ may\ be\ any\ string.\n\nUnlike\ a\ \[dict%|%dictionary\],\ an\ array\ is\ not\ a\ single\ value.\ \ Instead,\ the\nname\ of\ the\ array\ is\ used\ as\ a\ \[handle\],\ and\ is\ passed\ to\ `\[array\]`\ commands\ in\norder\ to\ perform\ some\ operation\ on\ the\ array\ such\ as\ reading\ the\ value\ of\ some\nvariable\ in\ the\ array.\ \ The\ array\ itself,\ being\ a\ \[container\],\ does\ not\ have\ a\ value\ that\ can\ be\ read.\ \ However,\ `\[array\ get\]`\ returns\ a\ \[dict\]\ representing\npart\ or\ all\ of\ the\ array.\n\nInternally,\ Tcl\ uses\ a\ \[hash\]\ table\ to\ implement\ an\ array.\ \ An\ array\ and\ a\n\[dict%|%dictionary\]\ are\ similar\ in\ functionaly,\ but\ each\ has\ qualities\ that\ndistinguish\ it.\ \ `\[trace\]`\ and\ `\[upvar\]`\ both\ can\ operate\ on\ array\ member\nvariables,\ but\ not\ on\ elements\ in\ a\ dictionary.\n\nNeither\ `array`\ nor\ `\[dict\]`\ are\ the\ direct\ script-level\ equivalent\ of\ Tcl's\ninternal\ \[hash\]\ tables,\ but\ a\ dictionary\ is\ the\ more\ minimal\ interface\ to\ them.\nPrior\ to\ the\ \[Changes\ in\ Tcl/Tk\ 8.5%|%introduction\]\ of\ `\[dict\]`,\ arrays\ were\nthe\ Tcl\ script-level\ facility\ bearing\ the\ closest\ resemblence\ to\ such\nstructures,\ so\ they\ were\ often\ conscripted\ to\ that\ end.\n\nArray\ keys\ are\ not\ ordered.\ \ It\ isn't\ straight-forward\ to\ get\ values\ out\ of\ an\narray\ in\ the\ same\ order\ that\ they\ were\ set.\ \ One\ common\ alternative\ is\ to\nget\ the\ names\ and\ then\ order\ them.\ \ In\ contrast,\ values\ in\ a\ `\[dict\]`\ are\nordered.\n\n\[trace%|%traces\]\ may\ be\ set\ on\ either\ an\ array\ container\ or\ an\ individual\ array\nvariable.\n\n\n\n**\ See\ Also\ **\n\n\ \ \ \[Arrays\ /\ hash\ maps\]:\ \ \ more\ details\ about\ arrays\n\n\ \ \ \[A\ simple\ database\]:\ \ \ \n\n\ \ \ \[container\]:\ \ \ a\ guide\ to\ containers\ in\ Tcl\n\n\ \ \ \[parray\]:\ \ \ \n\n\ \ \ \[Arrays\ as\ cached\ functions\]:\ \ \ \n\n\ \ \ \[Arrays\ of\ function\ pointers\]:\ \ \ \n\n\ \ \ \[Memory\ costs\ with\ Tcl\]:\ \ \ for\ measurement\ of\ array/list\ element\ consumption\ in\ bytes.\n\n\ \ \ \[Persistent\ arrays\]:\ \ \ \n\n\ \ \ \[Procedures\ stored\ in\ arrays\]:\ \ \ \n\n\ \ \ \[array\ name\ string\ matching\ extension\]:\ \ \ \n\ \ \ \n\ \ \ \[GUI\ for\ editing\ a\ Tcl\ array\]:\ \ \ \n\n\ \ \ \[Fitting\ a\ new\ Rear-End\ to\ Arrays\]:\ \ \ \n\n\ \ \ \[foreach\]:\ \ \ \n\n\ \ \ \[iterating\ through\ an\ array\]:\ \ \ \n\n\n\n**\ Creating\ an\ Array\ **\n\nTo\ create\ an\ array,\ `\[set\]`\ a\ variable\ within\ the\ array\ using\ the\n`''arrayName''(''key'')`\ form:\n\n======\nset\ balloon(color)\ red\n======\n\nor\ use\ `\[array\ set\]`:\n\n======\narray\ set\ balloon\ \{color\ red\}\n======\n\nTo\ create\ multiple\ array\ keys\ and\ values\ in\ one\ operation,\ use\ `\[array\ set\]`.\n\nTo\ create\ an\ empty\ array:\n\n======\narray\ set\ myArray\ \{\}\n======\n\nArray\ names\ have\ the\ same\ restrictions\ as\ any\ other\ Tcl\ variable.\n\nWhen\ using\ the\ braces\ \[dodekalogue%|%syntax\]\ of\ variable\ substitution,\ include\nthe\ parenthesis\ and\ the\ name\ of\ the\ member\ variable\ within\ the\ braces:\n\n======\narray\ unset\ \{this\ stuff\}\nset\ \{this\ stuff(one)\}\ 1\nparray\ \{this\ stuff\}\n======\n\nA\ common\ beginner\ mistake\ is\ to\ over-quote\ the\ name\ of\ the\ member\ variable:\n\n======none\n#warning,\ bad\ code\ ahead!\nset\ a(\"key\")\ value\ \;#->\ value\narray\ get\ a\ \;#->\ \{\"key\"\}\ value\n\nunset\ a\n\n#better:\nset\ a(key)\ value\ \;#->\ value\nvalue\narray\ get\ a\ \;#->\ key\ value\n======\n\nIn\ Tcl,\ \[everything\ is\ a\ string\].\ Quoting\ strings\ is\ mostly\ not\ necessary,\ and\ncan\ even\ be\ a\ problem,\ as\ in\ the\ previous\ example.\n\nIn\ the\ following\ example\ the\ double\ quotes\ are\ not\ needed\ because\ the\ values\ don't\ contain\ any\ special\ characters:\n\n======\n#unnecessary\ double\ quotes\narray\ set\ myArray\ \{\"element\"\ \"value\"\}\n======\n\nBetter\ syntax\ would\ be:\n\n======\narray\ set\ myArray\ \{element\ value\}\ \;#\ or:\nset\ myArray(element)\ value\n======\n\nMore\ examples:\n\n======\nunset\ x\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ #\ x\ doesn't\ exist\ at\ all\ anymore\nunset\ x\ \;\ array\ set\ x\ \{\}\ \ \ \ \ \ \ \;\ #\ x\ exists\ as\ an\ array\ but\ has\ no\ elements\narray\ unset\ x\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ #\ x\ doesn't\ exist\ at\ all\ anymore\n\nforeach\ idx\ \[array\ names\ x\]\ \{\n\ \ \ set\ x(\$idx)\ \{\}\n\}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ #\ array\ exists\ -\ all\ the\ elements\ still\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ exist,\ but\ values\ of\ each\ element\ are\ now\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ empty\n======\n\n======\narray\ set\ colors\ \{\n\ \ \ \ red\ \ \ #ff0000\n\ \ \ \ green\ #00ff00\n\ \ \ \ blue\ \ #0000ff\n\}\nforeach\ name\ \[array\ names\ colors\]\ \{\n\ \ \ \ puts\ \"\$name\ is\ \$colors(\$name)\"\n\}\n======\n\n\n\n**\ Retrieving\ the\ Value\ of\ an\ array\ key\ **\n\n======\n#\ use\ a\ literal\ key\nset\ value1\ \$ballon(color)\n#\ use\ a\ key\ within\ a\ variable\nset\ value2\ \$ballon(\$key)\n======\n\n----\n\n\[Iain\ B.\ Findleton\]\ 2004-06\ asked\ whether\ there\ were\ easier\ ways\ to\nread\ an\ array\ element,\ given\ that\ the\ name\ of\ the\ array\ was\ in\ a\nvariable\ and\ the\ array\ key\ was\ in\ a\ variable.\ \ His\ example\ was:\n\n======\neval\ \{set\ \$\{key\}(\$item)\}\n======\n\n\[DKF\]\ writes,\ Just\ remove\ `\[eval\]`\ from\ the\ outside\ (it\ just\ confuses\ things)\nand\ it'll\ be\ fine:\n\n======\nputs\ \[set\ \$\{key\}(\$item)\]\ \ \ \ \ \ \ \ \;#\ Read\nset\ \$\{key\}(\$item)\ \$val\ \ \ \ \ \ \ \ \ \ \;#\ Write\n======\n\nIf\ you're\ in\ a\ procedure,\ use\ `\[upvar\]`\ to\ create\ a\ local\ reference\ to\ the\narray\ so\ you\ get\ something\ like\ this:\n\n======\nupvar\ \$key\ v\nputs\ \$v(\$item)\nset\ v(\$item)\ \$val\n======\n\nIt's\ also\ possible\ using\ `\[upvar\]`\ to\ link\ to\ an\ array\ element,\ but\ I\ndon't\ recommend\ it\ (for\ example,\ it\ fails\ if\ you\ decide\ to\ set\ key\ equal\ to\n::env\ since\ env-var\ management\ is\ done\ via\ a\ whole-array\ trace).\n\n\n\n**\ Determine\ whether\ a\ Key\ Exists\ **\n\n======\ninfo\ exists\ array(key)\n======\n\nSee\ \[info\ exists\]\n\n\n\n**\ Unset\ an\ Array\ \ **\n\n======\nunset\ balloon\n======\n\n`\[array\ unset\]`\ provides\ a\ way\ to\ unset\ a\ subset\ of\ keys\n\n\n\n**\ Incrementing\ an\ Array,\ Creating\ it\ if\ it\ doesn't\ Exist\ **\n\nNewer\ versions\ of\ tcl\ already\ behave\ this\ way,\ but\ with\ older\ versions:\n\n======\nproc\ incrArrayElement\ \{var\ key\ \{incr\ 1\}\}\ \{\n\ \ \ \ upvar\ \$var\ a\ \n\ \ \ \ if\ \{\[info\ exists\ a(\$key)\]\}\ \{\n\ \ \ \ \ \ \ \ incr\ a(\$key)\ \$incr\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ set\ a(\$key)\ \$incr\n\ \ \ \ \}\ \n\}\n======\n\n\n**\ Simulating\ Multiple\ Dimensions\ **\n\nThere\ are\ no\ multi-dimensional\ arrays\ in\ Tcl\ but\ they\ can\ be\ simulated\ by\ a\nnaming\ convention:\n\n======\nset\ a(1,1)\ 0\ \;#\ set\ element\ 1,1\ to\ 0\n======\n\nThis\ works\ if\ the\ keys\ used\ do\ not\ contain\ the\ ','\ character.\ If\ the\ keys\ can\nbe\ arbitrary\ strings\ then\ one\ can\ use\ the\ \[list\]\ of\ the\ indices\ as\ name\ of\ the\ variable\ in\ the\ array:\n\n======\nset\ a(\[list\ \$i1\ \$i2\ \$i3\])\ 0\;\ #\ set\ element\ (i1,i2,i3)\ of\ array\ a\ to\ 0\n======\n\nThis\ is\ completely\ unambiguous,\ but\ might\ look\ a\ bit\ uglier\ than\ the\ comma\nsolution.\ \ Also\ remember\ that\n\n======\nset\ a(\[list\ 1\ 2\ 3\])\ 0\n======\n\nis\ equivalent\ to\n\n======\nset\ \{a(1\ 2\ 3)\}\ 0\n======\n\nbut\ not\ to\n\n======\n#wrong\ #\ args\nset\ a(1\ 2\ 3)\ 0\n======\n\nbecause\ the\ last\ example\ passes\ four\ argument\ to\ `\[set\]`.\n\n\[AMG\]:\ \ To\ implement\ multidimensional\ arrays,\ I\ often\ use\ the\ convention\ given\nabove\ (commas,\ not\ `\[list\]`,\ but\ that's\ a\ good\ idea),\ but\ it\ prevents\ me\ from\neasily\ getting\ a\ list\ of\ elements\ in\ any\ one\ dimension.\ \ For\ the\ following\narray:\n\n======\narray\ set\ data\ \{\n\ \ \ \ foo,x\ ecks\ \ \ \ foo,y\ why\ \ \ \ foo,z\ zed\n\ \ \ \ bar,x\ ECKS\ \ \ \ bar,y\ WHY\ \ \ \ bar,z\ ZED\n\}\n======\n\nI'd\ like\ some\ means\ to\ get\ a\ list\ `foo\ bar`.\ \ How\ is\ this\ useful?\ \ I\ have\nwritten\ many\ server\ programs\ that\ use\ multidimensions\ arrays\ to\ keep\ track\ of\nstate\ for\ all\ connected\ clients.\ \ To\ get\ a\ list\ of\ all\ client\ IDs,\ I\ have\nanother\ variable\ or\ special\ array\ element\ listing\ the\ client\ IDs,\ but\ I\ have\ to\nalways\ keep\ it\ in\ sync\ with\ the\ rest\ of\ the\ array.\ \ I\ dislike\ this.\n\nWhat\ if\ multidimensional\ arrays\ were\ accessed\ using\n'''`\$name(dim1)(dim2)(dim3)`'''\ syntax?\ \ Thanks\ to\ a\ bug,\ we\ once\ had\nmultidimensional\ arrays,\ but\ the\ syntax\ was\ of\ course\ very\ very\ weird\ (I\ think\nit\ used\ `\[uplevel\]\ 0`).\ \ This\ is\ a\ bit\ cleaner-looking.\ \ But\ it\ has\ very\ bad\ninteractions\ with\ `array`.\ \ How\ would\ the\ following\ be\ converted\ to\ use\n`\[array\ set\]`?\n\n======\nset\ data(foo)(x)\ ecks\;\ set\ data(foo)(y)\ why\;\ set\ data(foo)(z)\ zed\nset\ data(bar)(x)\ ECKS\;\ set\ data(bar)(y)\ WHY\;\ set\ data(bar)(z)\ ZED\n======\n\nWhat\ should\ `\[array\ get\]\ data`\ return?\ \n\n\[Lars\ H\]:\ Well,\ why\ don't\ you\ ask\ Tcl?\ :-)\ It\ would\ tell\ you\ that\ after\ the\nabove\ commands,\ `\[array\ get\]\ data`\ returns\n\n======\nbar)(z\ ZED\ foo)(x\ ecks\ bar)(x\ ECKS\ foo)(y\ why\ bar)(y\ WHY\ foo)(z\ zed\n======\n\nand\ (as\ an\ aid\ to\ help\ overcome\ one's\ prejudices\ about\ how\ the\ above\ should\ be\ninterpreted)\ \n\n======\njoin\ \[array\ names\ data\]\ \\n\n======\n\nreturns\n\n======none\nbar)(z\nfoo)(x\nbar)(x\nfoo)(y\nbar)(y\nfoo)(z\n======\n\nThis\ is\ a\ recurring\ problem\ with\ attempts\ to\ extend\ Tcl\ syntax:\ the\ \"new\nsyntaxes\"\ people\ come\ up\ with\ usually\ already\ mean\ something,\ even\ if\ that\n\"something\"\ looks\ rather\ silly.\n\n\[AMG\]:\ \ in\ response\ to\ Lars:\ Wow,\ I\ didn't\ realize\ Tcl\ would\ accept\ such\nsyntax!\ \ It\ turns\ out\ that\ I'm\ simply\ using\ '''`)(`'''\ as\ my\ dimension\ delimiter.\n\nAlright,\ now\ let's\ think\ about\ how\ to\ get\ a\ list\ of\ all\ elements\ ''in\ a\ given\ndimension.''\ \ This\ is\ easiest\ to\ do\ if\ the\ array\ indices\ are\ proper\ lists:\n\n======\narray\ set\ data\ \[list\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \\\n\ \ \ \ \[list\ foo\ x\]\ ecks\ \ \ \ \[list\ foo\ y\]\ why\ \ \ \ \[list\ foo\ z\]\ zed\\\n\ \ \ \ \[list\ bar\ x\]\ ECKS\ \ \ \ \[list\ bar\ y\]\ WHY\ \ \ \ \[list\ bar\ z\]\ ZED\\\n\]\n\nproc\ array_dimnames\ \{array_var\ dim_index\}\ \{\n\ \ \ \ upvar\ 1\ \$array_var\ array\n\ \ \ \ set\ result\ \[list\]\n\ \ \ \ foreach\ name\ \[lsort\ -unique\ -index\ \$dim_index\ \[array\ names\ array\]\]\ \{\n\ \ \ \ \ \ \ \ lappend\ result\ \[lindex\ \$name\ \$dim_index\]\n\ \ \ \ \}\n\ \ \ \ return\ \$result\n\}\n\n%\ array_dimnames\ data\ 0\nbar\ foo\n%\ array_dimnames\ data\ 1\nx\ y\ z\n======\n\nThat\ works.\ \ For\ other\ delimiters,\ each\ element\ of\ `\[array\ names\]`\ needs\ to\nbe\ `\[split\]`\ before\ the\ list\ can\ be\ passed\ to\ `\[lsort\]`.\ \ Another\ job\ for\n`\[lcomp\]`\ I\ guess.\n\nFor\ really\ big\ arrays\ such\ as\ the\ enormous\ '''MV'''\ catchall\ array\ used\ in\n\[OpenVerse\],\ I\ wonder\ if\ this\ costs\ too\ much,\ so\ much\ that\ it's\ worth\ it\ to\nseparately\ maintain\ element\ lists\ rather\ than\ extract\ that\ information\ from\ the\narray\ names.\n\n\[AMG\]:\ \ Continued\ from\ before:\ `\[array\ names\]\ data`\ should\ return\ `foo\ bar`,\nbut\ `\$data(foo)`\ wouldn't\ be\ valid,\ breaking\ old\ assumptions.\ \ Should\n`\[set\]\ data(foo)\ dummy`\ unset\ `data(foo)(*)`?\ \ And\ so\ on.\n\nIf\ array\ notation\ could\ be\ applied\ to\ \[dict\]s\ we'd\ be\ in\ great\ shape.\ \ Doesn't\n\[Jim\]\ do\ this?\n\n\[Lars\ H\]:\ \ Why\ don't\ you\ just\ use\ nested\ \[dict\]s?\ \ It\ seems\ those\ will\ do\nprecisely\ what\ you\ ask\ for\ above.\n\n\[AMG\]:\ \ I\ can\ do\ some\ things\ with\ '''array'''s\ that\ I\ can't\ do\ with\ \[dict\]s:\nnamely,\ \[trace%|%traces\]\ and\ \[upvar%|%upvars\]\ and\ everything\ else\ that\ uses\ those\ features.\nSo,\ I\ often\ use\ arrays\ when\ I\ need\ to\ use\ elements\ as\n`-textvariable`s.\ \ Perhaps\ I\ should\ be\ using\ \[namespace%|%namespaces\]\ instead,\npreferably\ wrapped\ by\ \[snit\].\n\n----\n\n\[LV\]:\ \ Over\ on\ \[comp.lang.tcl\],\ 2007-02,\ \ ''Fredderic''\ provides\ the\ following\n\[proc\]\ in\ response\ to\ someone\ who\ was\ to\ declare\ an\ empty\ array\ at\ the\ start\ of\na\ Tcl\ script.\n\n======\nproc\ declare_array\ arrayName\ \{\n\ \ \ \ upvar\ 1\ \$arrayName\ array\n\ \ \ \ catch\ \{unset\ array\}\n\ \ \ \ array\ set\ array\ \{\}\n\}\ \n======\n\nThe\ idea\ here\ is\ to\ `\[catch\]`\ the\ `\[unset\]`\ in\ case\ the\ variable\ was\ not\ already\ndeclared.\ Then,\ `\[array\ set\]`\ makes\ the\ variable\ an\ array,\ but\ without\ any\nmembers.\ \ That\ way,\ a\ later\ reference\ to\ the\ name\ in\ a\ non-array\ setting\ngenerates\ a\ ''variable\ is\ array''\ error.\n----\n'''\[hkassem\]\ -\ 2015-12-15\ 11:52:49'''\n\n======\n\[HKASSEM\]\n\nproc\ array_sort\ \{index\ val\ _foreach_sorting_array_ref\ foreachsorting_command\}\ \{\n\ \ \ \ #\ _foreach_sorting_array_ref\ is\ a\ reference\ this\ mean\ equivalent\ to\ &array\ in\ C\n\ \ \ \ upvar\ \$_foreach_sorting_array_ref\ arrref\n\ \ \ \ upvar\ \$index\ i\n\ \ \ \ upvar\ \$val\ v\n\ \ \ \ \ \ \ \ \n\ \ \ \ set\ x\ \[list\]\n\ \ \ \ foreach\ \{k\ vl\}\ \[array\ get\ arrref\]\ \{\n\ \ \ \ \ \ \ \ lappend\ x\ \[list\ \$k\ \$vl\]\n\ \ \ \ \}\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ foreach\ e\ \[lsort\ -integer\ -decreasing\ -index\ 1\ \$x\]\ \{\n\ \ \ \ \ \ \ \ #puts\ \"\$i,\$v\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ i\ \[lindex\ \$e\ 0\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ v\ \[lindex\ \$e\ 1\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ -------\ FOREACH\ BODY\ ------------<\n\ \ \ \ \ \ \ \ uplevel\ \$foreachsorting_command\n\ \ \ \ \ \ \ \ #\ ------END\ FOREACH\ BODY----------->\n\ \ \ \ \ \ \ \ \}\ \ \n\}\n\nusage:\nset\ myarr(1)\ 20\nset\ myarr(2)\ 10\nset\ myarr(3)\ 30\narray_sort\ index\ value\ myarr\ \{\n\ \ #\ actions\n\ \ \ puts\ \"\$index\ \$value\"\n\}\n\noutput:\n3\ 30\n1\ 20\n2\ 10 regexp2} CALL {my render array '''`\[http://www.tcl.tk/man/tcl/TclCmd/array.htm%|%array\]`'''\ is\ a\ \[Tcl\ Commands%|%built-in\]\ ensemble\ of\ \[command%|%commands\]\ that\ manipulates\ \[Tcl\]'s\ array\ variables.\ \ Array\ variables\ can\ also\ be\nmanipulated\ using\ \[Dodekalogue%|%''arrayName''(''key'')\]\ syntax.\n\n\n\n**\ Synopsis\ **\n\n\ \ \ \ :\ \ \ '''\[array\ anymore\]'''\ ''arrayName\ searchId''\n\n\ \ \ \ :\ \ \ '''\[array\ donesearch\]'''\ ''arrayName\ searchId''\n\n\ \ \ \ :\ \ \ '''\[array\ exists\]'''\ ''arrayName''\n\n\ \ \ \ :\ \ \ '''\[array\ get\]'''\ ''arrayName\ ''?''pattern''?\n\n\ \ \ \ :\ \ \ '''\[array\ names\]'''\ ''arrayName\ ''?''mode''?\ ?''pattern''?\n\n\ \ \ \ :\ \ \ '''\[array\ nextelement\]'''\ ''arrayName\ searchId''\n\n\ \ \ \ :\ \ \ '''\[array\ set\]'''\ ''arrayName\ list''\n\n\ \ \ \ :\ \ \ '''\[array\ size\]'''\ ''arrayName''\n\n\ \ \ \ :\ \ \ '''\[array\ startsearch\]'''\ ''arrayName''\n\n\ \ \ \ :\ \ \ '''\[array\ statistics\]'''\ ''arrayName''\n\n\ \ \ \ :\ \ \ '''\[array\ unset\]'''\ ''arrayName\ ''?''pattern''?\n\n\n\n**\ Documentation\ **\n\n\ \ \ \[http://www.tcl.tk/man/tcl/TclCmd/array.htm%|%man\ page\]:\ \ \ \n\n\n\n**\ Description\ **\n\nA\ Tcl\ '''array'''\ is\ a\ \[container\]\ of\ variables.\ \ Tcl's\n\[Dodekalogue%|%two-component\]\ `\$''arrayName''(''key'')`\ syntax\ can\ be\ used\ to\n\[variable\ substitution%|%substitute\]\ individual\ values\ of\ an\ array.\ \ The\ name\nof\ a\ variable\ in\ an\ array\ may\ be\ any\ string.\n\nUnlike\ a\ \[dict%|%dictionary\],\ an\ array\ is\ not\ a\ single\ value.\ \ Instead,\ the\nname\ of\ the\ array\ is\ used\ as\ a\ \[handle\],\ and\ is\ passed\ to\ `\[array\]`\ commands\ in\norder\ to\ perform\ some\ operation\ on\ the\ array\ such\ as\ reading\ the\ value\ of\ some\nvariable\ in\ the\ array.\ \ The\ array\ itself,\ being\ a\ \[container\],\ does\ not\ have\ a\ value\ that\ can\ be\ read.\ \ However,\ `\[array\ get\]`\ returns\ a\ \[dict\]\ representing\npart\ or\ all\ of\ the\ array.\n\nInternally,\ Tcl\ uses\ a\ \[hash\]\ table\ to\ implement\ an\ array.\ \ An\ array\ and\ a\n\[dict%|%dictionary\]\ are\ similar\ in\ functionaly,\ but\ each\ has\ qualities\ that\ndistinguish\ it.\ \ `\[trace\]`\ and\ `\[upvar\]`\ both\ can\ operate\ on\ array\ member\nvariables,\ but\ not\ on\ elements\ in\ a\ dictionary.\n\nNeither\ `array`\ nor\ `\[dict\]`\ are\ the\ direct\ script-level\ equivalent\ of\ Tcl's\ninternal\ \[hash\]\ tables,\ but\ a\ dictionary\ is\ the\ more\ minimal\ interface\ to\ them.\nPrior\ to\ the\ \[Changes\ in\ Tcl/Tk\ 8.5%|%introduction\]\ of\ `\[dict\]`,\ arrays\ were\nthe\ Tcl\ script-level\ facility\ bearing\ the\ closest\ resemblence\ to\ such\nstructures,\ so\ they\ were\ often\ conscripted\ to\ that\ end.\n\nArray\ keys\ are\ not\ ordered.\ \ It\ isn't\ straight-forward\ to\ get\ values\ out\ of\ an\narray\ in\ the\ same\ order\ that\ they\ were\ set.\ \ One\ common\ alternative\ is\ to\nget\ the\ names\ and\ then\ order\ them.\ \ In\ contrast,\ values\ in\ a\ `\[dict\]`\ are\nordered.\n\n\[trace%|%traces\]\ may\ be\ set\ on\ either\ an\ array\ container\ or\ an\ individual\ array\nvariable.\n\n\n\n**\ See\ Also\ **\n\n\ \ \ \[Arrays\ /\ hash\ maps\]:\ \ \ more\ details\ about\ arrays\n\n\ \ \ \[A\ simple\ database\]:\ \ \ \n\n\ \ \ \[container\]:\ \ \ a\ guide\ to\ containers\ in\ Tcl\n\n\ \ \ \[parray\]:\ \ \ \n\n\ \ \ \[Arrays\ as\ cached\ functions\]:\ \ \ \n\n\ \ \ \[Arrays\ of\ function\ pointers\]:\ \ \ \n\n\ \ \ \[Memory\ costs\ with\ Tcl\]:\ \ \ for\ measurement\ of\ array/list\ element\ consumption\ in\ bytes.\n\n\ \ \ \[Persistent\ arrays\]:\ \ \ \n\n\ \ \ \[Procedures\ stored\ in\ arrays\]:\ \ \ \n\n\ \ \ \[array\ name\ string\ matching\ extension\]:\ \ \ \n\ \ \ \n\ \ \ \[GUI\ for\ editing\ a\ Tcl\ array\]:\ \ \ \n\n\ \ \ \[Fitting\ a\ new\ Rear-End\ to\ Arrays\]:\ \ \ \n\n\ \ \ \[foreach\]:\ \ \ \n\n\ \ \ \[iterating\ through\ an\ array\]:\ \ \ \n\n\n\n**\ Creating\ an\ Array\ **\n\nTo\ create\ an\ array,\ `\[set\]`\ a\ variable\ within\ the\ array\ using\ the\n`''arrayName''(''key'')`\ form:\n\n======\nset\ balloon(color)\ red\n======\n\nor\ use\ `\[array\ set\]`:\n\n======\narray\ set\ balloon\ \{color\ red\}\n======\n\nTo\ create\ multiple\ array\ keys\ and\ values\ in\ one\ operation,\ use\ `\[array\ set\]`.\n\nTo\ create\ an\ empty\ array:\n\n======\narray\ set\ myArray\ \{\}\n======\n\nArray\ names\ have\ the\ same\ restrictions\ as\ any\ other\ Tcl\ variable.\n\nWhen\ using\ the\ braces\ \[dodekalogue%|%syntax\]\ of\ variable\ substitution,\ include\nthe\ parenthesis\ and\ the\ name\ of\ the\ member\ variable\ within\ the\ braces:\n\n======\narray\ unset\ \{this\ stuff\}\nset\ \{this\ stuff(one)\}\ 1\nparray\ \{this\ stuff\}\n======\n\nA\ common\ beginner\ mistake\ is\ to\ over-quote\ the\ name\ of\ the\ member\ variable:\n\n======none\n#warning,\ bad\ code\ ahead!\nset\ a(\"key\")\ value\ \;#->\ value\narray\ get\ a\ \;#->\ \{\"key\"\}\ value\n\nunset\ a\n\n#better:\nset\ a(key)\ value\ \;#->\ value\nvalue\narray\ get\ a\ \;#->\ key\ value\n======\n\nIn\ Tcl,\ \[everything\ is\ a\ string\].\ Quoting\ strings\ is\ mostly\ not\ necessary,\ and\ncan\ even\ be\ a\ problem,\ as\ in\ the\ previous\ example.\n\nIn\ the\ following\ example\ the\ double\ quotes\ are\ not\ needed\ because\ the\ values\ don't\ contain\ any\ special\ characters:\n\n======\n#unnecessary\ double\ quotes\narray\ set\ myArray\ \{\"element\"\ \"value\"\}\n======\n\nBetter\ syntax\ would\ be:\n\n======\narray\ set\ myArray\ \{element\ value\}\ \;#\ or:\nset\ myArray(element)\ value\n======\n\nMore\ examples:\n\n======\nunset\ x\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ #\ x\ doesn't\ exist\ at\ all\ anymore\nunset\ x\ \;\ array\ set\ x\ \{\}\ \ \ \ \ \ \ \;\ #\ x\ exists\ as\ an\ array\ but\ has\ no\ elements\narray\ unset\ x\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ #\ x\ doesn't\ exist\ at\ all\ anymore\n\nforeach\ idx\ \[array\ names\ x\]\ \{\n\ \ \ set\ x(\$idx)\ \{\}\n\}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \;\ #\ array\ exists\ -\ all\ the\ elements\ still\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ exist,\ but\ values\ of\ each\ element\ are\ now\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ empty\n======\n\n======\narray\ set\ colors\ \{\n\ \ \ \ red\ \ \ #ff0000\n\ \ \ \ green\ #00ff00\n\ \ \ \ blue\ \ #0000ff\n\}\nforeach\ name\ \[array\ names\ colors\]\ \{\n\ \ \ \ puts\ \"\$name\ is\ \$colors(\$name)\"\n\}\n======\n\n\n\n**\ Retrieving\ the\ Value\ of\ an\ array\ key\ **\n\n======\n#\ use\ a\ literal\ key\nset\ value1\ \$ballon(color)\n#\ use\ a\ key\ within\ a\ variable\nset\ value2\ \$ballon(\$key)\n======\n\n----\n\n\[Iain\ B.\ Findleton\]\ 2004-06\ asked\ whether\ there\ were\ easier\ ways\ to\nread\ an\ array\ element,\ given\ that\ the\ name\ of\ the\ array\ was\ in\ a\nvariable\ and\ the\ array\ key\ was\ in\ a\ variable.\ \ His\ example\ was:\n\n======\neval\ \{set\ \$\{key\}(\$item)\}\n======\n\n\[DKF\]\ writes,\ Just\ remove\ `\[eval\]`\ from\ the\ outside\ (it\ just\ confuses\ things)\nand\ it'll\ be\ fine:\n\n======\nputs\ \[set\ \$\{key\}(\$item)\]\ \ \ \ \ \ \ \ \;#\ Read\nset\ \$\{key\}(\$item)\ \$val\ \ \ \ \ \ \ \ \ \ \;#\ Write\n======\n\nIf\ you're\ in\ a\ procedure,\ use\ `\[upvar\]`\ to\ create\ a\ local\ reference\ to\ the\narray\ so\ you\ get\ something\ like\ this:\n\n======\nupvar\ \$key\ v\nputs\ \$v(\$item)\nset\ v(\$item)\ \$val\n======\n\nIt's\ also\ possible\ using\ `\[upvar\]`\ to\ link\ to\ an\ array\ element,\ but\ I\ndon't\ recommend\ it\ (for\ example,\ it\ fails\ if\ you\ decide\ to\ set\ key\ equal\ to\n::env\ since\ env-var\ management\ is\ done\ via\ a\ whole-array\ trace).\n\n\n\n**\ Determine\ whether\ a\ Key\ Exists\ **\n\n======\ninfo\ exists\ array(key)\n======\n\nSee\ \[info\ exists\]\n\n\n\n**\ Unset\ an\ Array\ \ **\n\n======\nunset\ balloon\n======\n\n`\[array\ unset\]`\ provides\ a\ way\ to\ unset\ a\ subset\ of\ keys\n\n\n\n**\ Incrementing\ an\ Array,\ Creating\ it\ if\ it\ doesn't\ Exist\ **\n\nNewer\ versions\ of\ tcl\ already\ behave\ this\ way,\ but\ with\ older\ versions:\n\n======\nproc\ incrArrayElement\ \{var\ key\ \{incr\ 1\}\}\ \{\n\ \ \ \ upvar\ \$var\ a\ \n\ \ \ \ if\ \{\[info\ exists\ a(\$key)\]\}\ \{\n\ \ \ \ \ \ \ \ incr\ a(\$key)\ \$incr\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ set\ a(\$key)\ \$incr\n\ \ \ \ \}\ \n\}\n======\n\n\n**\ Simulating\ Multiple\ Dimensions\ **\n\nThere\ are\ no\ multi-dimensional\ arrays\ in\ Tcl\ but\ they\ can\ be\ simulated\ by\ a\nnaming\ convention:\n\n======\nset\ a(1,1)\ 0\ \;#\ set\ element\ 1,1\ to\ 0\n======\n\nThis\ works\ if\ the\ keys\ used\ do\ not\ contain\ the\ ','\ character.\ If\ the\ keys\ can\nbe\ arbitrary\ strings\ then\ one\ can\ use\ the\ \[list\]\ of\ the\ indices\ as\ name\ of\ the\ variable\ in\ the\ array:\n\n======\nset\ a(\[list\ \$i1\ \$i2\ \$i3\])\ 0\;\ #\ set\ element\ (i1,i2,i3)\ of\ array\ a\ to\ 0\n======\n\nThis\ is\ completely\ unambiguous,\ but\ might\ look\ a\ bit\ uglier\ than\ the\ comma\nsolution.\ \ Also\ remember\ that\n\n======\nset\ a(\[list\ 1\ 2\ 3\])\ 0\n======\n\nis\ equivalent\ to\n\n======\nset\ \{a(1\ 2\ 3)\}\ 0\n======\n\nbut\ not\ to\n\n======\n#wrong\ #\ args\nset\ a(1\ 2\ 3)\ 0\n======\n\nbecause\ the\ last\ example\ passes\ four\ argument\ to\ `\[set\]`.\n\n\[AMG\]:\ \ To\ implement\ multidimensional\ arrays,\ I\ often\ use\ the\ convention\ given\nabove\ (commas,\ not\ `\[list\]`,\ but\ that's\ a\ good\ idea),\ but\ it\ prevents\ me\ from\neasily\ getting\ a\ list\ of\ elements\ in\ any\ one\ dimension.\ \ For\ the\ following\narray:\n\n======\narray\ set\ data\ \{\n\ \ \ \ foo,x\ ecks\ \ \ \ foo,y\ why\ \ \ \ foo,z\ zed\n\ \ \ \ bar,x\ ECKS\ \ \ \ bar,y\ WHY\ \ \ \ bar,z\ ZED\n\}\n======\n\nI'd\ like\ some\ means\ to\ get\ a\ list\ `foo\ bar`.\ \ How\ is\ this\ useful?\ \ I\ have\nwritten\ many\ server\ programs\ that\ use\ multidimensions\ arrays\ to\ keep\ track\ of\nstate\ for\ all\ connected\ clients.\ \ To\ get\ a\ list\ of\ all\ client\ IDs,\ I\ have\nanother\ variable\ or\ special\ array\ element\ listing\ the\ client\ IDs,\ but\ I\ have\ to\nalways\ keep\ it\ in\ sync\ with\ the\ rest\ of\ the\ array.\ \ I\ dislike\ this.\n\nWhat\ if\ multidimensional\ arrays\ were\ accessed\ using\n'''`\$name(dim1)(dim2)(dim3)`'''\ syntax?\ \ Thanks\ to\ a\ bug,\ we\ once\ had\nmultidimensional\ arrays,\ but\ the\ syntax\ was\ of\ course\ very\ very\ weird\ (I\ think\nit\ used\ `\[uplevel\]\ 0`).\ \ This\ is\ a\ bit\ cleaner-looking.\ \ But\ it\ has\ very\ bad\ninteractions\ with\ `array`.\ \ How\ would\ the\ following\ be\ converted\ to\ use\n`\[array\ set\]`?\n\n======\nset\ data(foo)(x)\ ecks\;\ set\ data(foo)(y)\ why\;\ set\ data(foo)(z)\ zed\nset\ data(bar)(x)\ ECKS\;\ set\ data(bar)(y)\ WHY\;\ set\ data(bar)(z)\ ZED\n======\n\nWhat\ should\ `\[array\ get\]\ data`\ return?\ \n\n\[Lars\ H\]:\ Well,\ why\ don't\ you\ ask\ Tcl?\ :-)\ It\ would\ tell\ you\ that\ after\ the\nabove\ commands,\ `\[array\ get\]\ data`\ returns\n\n======\nbar)(z\ ZED\ foo)(x\ ecks\ bar)(x\ ECKS\ foo)(y\ why\ bar)(y\ WHY\ foo)(z\ zed\n======\n\nand\ (as\ an\ aid\ to\ help\ overcome\ one's\ prejudices\ about\ how\ the\ above\ should\ be\ninterpreted)\ \n\n======\njoin\ \[array\ names\ data\]\ \\n\n======\n\nreturns\n\n======none\nbar)(z\nfoo)(x\nbar)(x\nfoo)(y\nbar)(y\nfoo)(z\n======\n\nThis\ is\ a\ recurring\ problem\ with\ attempts\ to\ extend\ Tcl\ syntax:\ the\ \"new\nsyntaxes\"\ people\ come\ up\ with\ usually\ already\ mean\ something,\ even\ if\ that\n\"something\"\ looks\ rather\ silly.\n\n\[AMG\]:\ \ in\ response\ to\ Lars:\ Wow,\ I\ didn't\ realize\ Tcl\ would\ accept\ such\nsyntax!\ \ It\ turns\ out\ that\ I'm\ simply\ using\ '''`)(`'''\ as\ my\ dimension\ delimiter.\n\nAlright,\ now\ let's\ think\ about\ how\ to\ get\ a\ list\ of\ all\ elements\ ''in\ a\ given\ndimension.''\ \ This\ is\ easiest\ to\ do\ if\ the\ array\ indices\ are\ proper\ lists:\n\n======\narray\ set\ data\ \[list\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \\\n\ \ \ \ \[list\ foo\ x\]\ ecks\ \ \ \ \[list\ foo\ y\]\ why\ \ \ \ \[list\ foo\ z\]\ zed\\\n\ \ \ \ \[list\ bar\ x\]\ ECKS\ \ \ \ \[list\ bar\ y\]\ WHY\ \ \ \ \[list\ bar\ z\]\ ZED\\\n\]\n\nproc\ array_dimnames\ \{array_var\ dim_index\}\ \{\n\ \ \ \ upvar\ 1\ \$array_var\ array\n\ \ \ \ set\ result\ \[list\]\n\ \ \ \ foreach\ name\ \[lsort\ -unique\ -index\ \$dim_index\ \[array\ names\ array\]\]\ \{\n\ \ \ \ \ \ \ \ lappend\ result\ \[lindex\ \$name\ \$dim_index\]\n\ \ \ \ \}\n\ \ \ \ return\ \$result\n\}\n\n%\ array_dimnames\ data\ 0\nbar\ foo\n%\ array_dimnames\ data\ 1\nx\ y\ z\n======\n\nThat\ works.\ \ For\ other\ delimiters,\ each\ element\ of\ `\[array\ names\]`\ needs\ to\nbe\ `\[split\]`\ before\ the\ list\ can\ be\ passed\ to\ `\[lsort\]`.\ \ Another\ job\ for\n`\[lcomp\]`\ I\ guess.\n\nFor\ really\ big\ arrays\ such\ as\ the\ enormous\ '''MV'''\ catchall\ array\ used\ in\n\[OpenVerse\],\ I\ wonder\ if\ this\ costs\ too\ much,\ so\ much\ that\ it's\ worth\ it\ to\nseparately\ maintain\ element\ lists\ rather\ than\ extract\ that\ information\ from\ the\narray\ names.\n\n\[AMG\]:\ \ Continued\ from\ before:\ `\[array\ names\]\ data`\ should\ return\ `foo\ bar`,\nbut\ `\$data(foo)`\ wouldn't\ be\ valid,\ breaking\ old\ assumptions.\ \ Should\n`\[set\]\ data(foo)\ dummy`\ unset\ `data(foo)(*)`?\ \ And\ so\ on.\n\nIf\ array\ notation\ could\ be\ applied\ to\ \[dict\]s\ we'd\ be\ in\ great\ shape.\ \ Doesn't\n\[Jim\]\ do\ this?\n\n\[Lars\ H\]:\ \ Why\ don't\ you\ just\ use\ nested\ \[dict\]s?\ \ It\ seems\ those\ will\ do\nprecisely\ what\ you\ ask\ for\ above.\n\n\[AMG\]:\ \ I\ can\ do\ some\ things\ with\ '''array'''s\ that\ I\ can't\ do\ with\ \[dict\]s:\nnamely,\ \[trace%|%traces\]\ and\ \[upvar%|%upvars\]\ and\ everything\ else\ that\ uses\ those\ features.\nSo,\ I\ often\ use\ arrays\ when\ I\ need\ to\ use\ elements\ as\n`-textvariable`s.\ \ Perhaps\ I\ should\ be\ using\ \[namespace%|%namespaces\]\ instead,\npreferably\ wrapped\ by\ \[snit\].\n\n----\n\n\[LV\]:\ \ Over\ on\ \[comp.lang.tcl\],\ 2007-02,\ \ ''Fredderic''\ provides\ the\ following\n\[proc\]\ in\ response\ to\ someone\ who\ was\ to\ declare\ an\ empty\ array\ at\ the\ start\ of\na\ Tcl\ script.\n\n======\nproc\ declare_array\ arrayName\ \{\n\ \ \ \ upvar\ 1\ \$arrayName\ array\n\ \ \ \ catch\ \{unset\ array\}\n\ \ \ \ array\ set\ array\ \{\}\n\}\ \n======\n\nThe\ idea\ here\ is\ to\ `\[catch\]`\ the\ `\[unset\]`\ in\ case\ the\ variable\ was\ not\ already\ndeclared.\ Then,\ `\[array\ set\]`\ makes\ the\ variable\ an\ array,\ but\ without\ any\nmembers.\ \ That\ way,\ a\ later\ reference\ to\ the\ name\ in\ a\ non-array\ setting\ngenerates\ a\ ''variable\ is\ array''\ error.\n----\n'''\[hkassem\]\ -\ 2015-12-15\ 11:52:49'''\n\n======\n\[HKASSEM\]\n\nproc\ array_sort\ \{index\ val\ _foreach_sorting_array_ref\ foreachsorting_command\}\ \{\n\ \ \ \ #\ _foreach_sorting_array_ref\ is\ a\ reference\ this\ mean\ equivalent\ to\ &array\ in\ C\n\ \ \ \ upvar\ \$_foreach_sorting_array_ref\ arrref\n\ \ \ \ upvar\ \$index\ i\n\ \ \ \ upvar\ \$val\ v\n\ \ \ \ \ \ \ \ \n\ \ \ \ set\ x\ \[list\]\n\ \ \ \ foreach\ \{k\ vl\}\ \[array\ get\ arrref\]\ \{\n\ \ \ \ \ \ \ \ lappend\ x\ \[list\ \$k\ \$vl\]\n\ \ \ \ \}\n\ \ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ foreach\ e\ \[lsort\ -integer\ -decreasing\ -index\ 1\ \$x\]\ \{\n\ \ \ \ \ \ \ \ #puts\ \"\$i,\$v\"\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ i\ \[lindex\ \$e\ 0\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ set\ v\ \[lindex\ \$e\ 1\]\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ -------\ FOREACH\ BODY\ ------------<\n\ \ \ \ \ \ \ \ uplevel\ \$foreachsorting_command\n\ \ \ \ \ \ \ \ #\ ------END\ FOREACH\ BODY----------->\n\ \ \ \ \ \ \ \ \}\ \ \n\}\n\nusage:\nset\ myarr(1)\ 20\nset\ myarr(2)\ 10\nset\ myarr(3)\ 30\narray_sort\ index\ value\ myarr\ \{\n\ \ #\ actions\n\ \ \ puts\ \"\$index\ \$value\"\n\}\n\noutput:\n3\ 30\n1\ 20\n2\ 10} CALL {my revision array} CALL {::oo::Obj909029 process revision/array} CALL {::oo::Obj909027 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