Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/Using+array+syntax+for%2C+well%2C+array+manipulation?V=0
QUERY_STRINGV=0
CONTENT_TYPE
DOCUMENT_URI/revision/Using+array+syntax+for,+well,+array+manipulation
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.70.131.190
REMOTE_PORT27334
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR3.144.238.20
HTTP_CF_RAY87e51d103e202d25-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.144.238.20
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 {Using array syntax for, well, array manipulation} \[Arjen\ Markus\]\ (17\ june\ 2018)\ In\ the\ discussion\ on\ adding\ RBC\ to\ Tk\nrecently\ on\ the\ Tcl\ core\ mailing\ list\ the\ idea\ of\ ''data\ objects''\ as\nimplemented\ in\ the\ original\ \[BLT\]\ extension\ was\ brought\ to\ my\ attention\n-\ see\ \[https://www.usenix.org/legacy/events/tcl98/tcl98/full_papers/howlett/howlett.pdf\].\nAnother\ extension\ that\ uses\ data\ objects\ as\ an\ alternative\ to\nlists,\ associative\ arrays\ and\ dicts\ is\ \[VecTcl\].\ But\ there\ are\ others\ as\nwell.\ We\ could\ conclude\ that\ the\ use\ of\ large/largish\ amounts\ of\ data\ is\na\ ubiquitous\ topic.\n\nWhile\ the\ actual\ implementation\ of\ such\ extensions\ is\ an\ interesting\ in\nits\ own,\ we\ can\ also\ look\ at\ the\ syntax\ that\ is\ used.\ One\ intriguing\naspect\ of\ BLT's\ vector\ data\ type\ is\ that\ you\ can\ use\ array\ syntax\ to\naccess\ the\ values.\n\nThis\ aspect\ inspired\ me\ to\ the\ following\ toy\ program:\n\n\ \ \ *\ At\ the\ script\ level\ we\ want\ to\ use\ a\ suitable\ syntax,\ such\ as\ the\ array\ syntax\ to\ access\ the\ values\ and\ even\ manipulate\ the\ values.\n\ \ \ *\ At\ the\ script\ level\ the\ actual\ implementation\ is\ irrelevant.\n\nThe\ toy\ program\ uses\ the\ \[trace\]\ command\ to\ separate\ the\nimplementation\ of\ data\ storage\ from\ the\ syntax.\ Borrowing\ from\ Fortran,\nit\ allows\ \"array\ sections\"\ as\ if\ they\ were\ array\ elements:\n\n======\n\ \ \ \ set\ array(1:10)\ \{1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\ 10\}\n======\n\ndoes\ not\ set\ an\ array\ element\ \"1:10\"\ but\ is\ expanded\ to\ 10\nvirtual\ elements\ that\ take\ as\ values\ 1,\ 2,\ 3,\ etc\ from\ the\ given\ list.\n\nThe\ implementation\ is\ rather\ limited\ -\ ideally\ you\ would\ want\ to\ have\nmultidimensional\ arrays\ and\ performance\ issues\ are\ completely\ ignored.\nThink\ of\ storing\ 10\ million\ data,\ filtering\ them\ with\ some\ criterium\nand\ summing\ the\ result.\ You\ would\ want\ to\ have\ most\ of\ that\ done\ in\nlow-level\ languages\ like\ C,\ just\ not\ the\ specification:\n\n======\n\ \ \ \ puts\ \"Sum\ of\ positive\ values:\ \[sum\ \[filter\ x\ \{\$x\ >\ 0.0\}\ \$data\]\]\"\n======\n\nor\ some\ such\ functionality.\n\nWell,\ enough\ explanation.\ Here\ is\ the\ program:\n\n======\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ array_obj.tcl\ --\n#\ \ \ \ \ Use\ the\ ideas\ behind\ BLT's\ vector\ objects\ in\ a\ pure\ Tcl\ fashion:\n#\ \ \ \ \ -\ a\ Tcl\ array\ is\ backed\ up\ by\ \"private\"\ data\n#\ \ \ \ \ -\ the\ array\ syntax\ is\ used\ to\ access\ these\ data\n#\ \ \ \ \ -\ traces\ allow\ access\ to\ the\ actual\ data\n#\nproc\ mkarray\ \{name\ size\}\ \{\n\ \ \ \ global\ _\$name\n\ \ \ \ upvar\ 1\ \$name\ arrayName\n\n\ \ \ \ set\ _\$name\ \[lrepeat\ \$size\ 0\]\n\n\ \ \ \ trace\ add\ variable\ arrayName\ read\ \ readElement\n\ \ \ \ trace\ add\ variable\ arrayName\ write\ writeElement\n\}\n\nproc\ readElement\ \{arrayName\ element\ op\}\ \{\n\ \ \ \ global\ _\$arrayName\n\ \ \ \ upvar\ 1\ \$arrayName\ array\n\n\ \ \ \ if\ \{\ \[string\ first\ :\ \$element\]\ <\ 0\ \}\ \{\n\ \ \ \ \ \ \ \ set\ array(\$element)\ \[lindex\ \[set\ _\$arrayName\]\ \$element\]\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ regexp\ \{(\\d+):(\\d+)\}\ \$element\ =>\ first\ last\n\ \ \ \ \ \ \ \ set\ array(\$element)\ \[lrange\ \[set\ _\$arrayName\]\ \$first\ \$last\]\n\ \ \ \ \}\n\}\n\nproc\ writeElement\ \{arrayName\ element\ op\}\ \{\n\ \ \ \ global\ _\$arrayName\n\ \ \ \ upvar\ 1\ \$arrayName\ array\n\n\ \ \ \ if\ \{\ \[string\ first\ :\ \$element\]\ <\ 0\ \}\ \{\n\ \ \ \ \ \ \ \ lset\ _\$arrayName\ \$element\ \$array(\$element)\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ regexp\ \{(\\d+):(\\d+)\}\ \$element\ =>\ first\ last\n\n\ \ \ \ \ \ \ \ incr\ first\ -1\n\ \ \ \ \ \ \ \ incr\ last\ \ \ 1\n\ \ \ \ \ \ \ \ if\ \{\ \[llength\ \$array(\$element)\]\ >\ 1\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ _\$arrayName\ \[concat\ \[lrange\ \[set\ _\$arrayName\]\ 0\ \$first\]\ \ \ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$array(\$element)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[lrange\ \[set\ _\$arrayName\]\ \$last\ end\]\]\n\ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ _\$arrayName\ \[concat\ \[lrange\ \ \[set\ _\$arrayName\]\ 0\ \$first\]\ \ \ \ \ \ \ \ \ \ \ \ \ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[lrepeat\ \[expr\ \{\$last-\$first-1\}\]\ \$array(\$element)\]\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[lrange\ \ \[set\ _\$arrayName\]\ \$last\ end\]\]\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\}\n\n#\n#\ Demonstrate\ the\ idea\ ...\n#\nmkarray\ x\ 100\n\nset\ x(1)\ 2\nputs\ \"x:\ \$x(1)\"\n\nset\ x(2:11)\ \{1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\ 10\}\nputs\ \$x(0:15)\n\nset\ x(0:4)\ 11\nputs\ \$x(0:15)\n\n#\ Now\ iterate\ over\ a\ part\ of\ the\ array\nset\ sum\ 0\nforeach\ v\ \$x(0:20)\ \{\n\ \ \ \ set\ sum\ \[expr\ \{\$sum\ +\ \$v**2\}\]\n\}\nputs\ \"Sum\ of\ squares:\ \$sum\"\n\n#\ Or:\nproc\ sum\ \{lambda\ list\}\ \{\n\ \ \ \ set\ result\ 0\n\ \ \ \ foreach\ item\ \$list\ \{\n\ \ \ \ \ \ \ \ set\ result\ \[expr\ \{\$result\ +\ \[apply\ \$lambda\ \$item\]\}\]\n\ \ \ \ \}\n\ \ \ \ return\ \$result\n\}\n\nputs\ \"Sum\ of\ squares:\ \[sum\ \{v\ \{expr\ \{\$v**2\}\}\}\ \$x(0:20)\]\"\n======\n\n<<categories>>\ \[Category\ Data\]|\[Category\ Mathematics\] regexp2} CALL {my render {Using array syntax for, well, array manipulation} \[Arjen\ Markus\]\ (17\ june\ 2018)\ In\ the\ discussion\ on\ adding\ RBC\ to\ Tk\nrecently\ on\ the\ Tcl\ core\ mailing\ list\ the\ idea\ of\ ''data\ objects''\ as\nimplemented\ in\ the\ original\ \[BLT\]\ extension\ was\ brought\ to\ my\ attention\n-\ see\ \[https://www.usenix.org/legacy/events/tcl98/tcl98/full_papers/howlett/howlett.pdf\].\nAnother\ extension\ that\ uses\ data\ objects\ as\ an\ alternative\ to\nlists,\ associative\ arrays\ and\ dicts\ is\ \[VecTcl\].\ But\ there\ are\ others\ as\nwell.\ We\ could\ conclude\ that\ the\ use\ of\ large/largish\ amounts\ of\ data\ is\na\ ubiquitous\ topic.\n\nWhile\ the\ actual\ implementation\ of\ such\ extensions\ is\ an\ interesting\ in\nits\ own,\ we\ can\ also\ look\ at\ the\ syntax\ that\ is\ used.\ One\ intriguing\naspect\ of\ BLT's\ vector\ data\ type\ is\ that\ you\ can\ use\ array\ syntax\ to\naccess\ the\ values.\n\nThis\ aspect\ inspired\ me\ to\ the\ following\ toy\ program:\n\n\ \ \ *\ At\ the\ script\ level\ we\ want\ to\ use\ a\ suitable\ syntax,\ such\ as\ the\ array\ syntax\ to\ access\ the\ values\ and\ even\ manipulate\ the\ values.\n\ \ \ *\ At\ the\ script\ level\ the\ actual\ implementation\ is\ irrelevant.\n\nThe\ toy\ program\ uses\ the\ \[trace\]\ command\ to\ separate\ the\nimplementation\ of\ data\ storage\ from\ the\ syntax.\ Borrowing\ from\ Fortran,\nit\ allows\ \"array\ sections\"\ as\ if\ they\ were\ array\ elements:\n\n======\n\ \ \ \ set\ array(1:10)\ \{1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\ 10\}\n======\n\ndoes\ not\ set\ an\ array\ element\ \"1:10\"\ but\ is\ expanded\ to\ 10\nvirtual\ elements\ that\ take\ as\ values\ 1,\ 2,\ 3,\ etc\ from\ the\ given\ list.\n\nThe\ implementation\ is\ rather\ limited\ -\ ideally\ you\ would\ want\ to\ have\nmultidimensional\ arrays\ and\ performance\ issues\ are\ completely\ ignored.\nThink\ of\ storing\ 10\ million\ data,\ filtering\ them\ with\ some\ criterium\nand\ summing\ the\ result.\ You\ would\ want\ to\ have\ most\ of\ that\ done\ in\nlow-level\ languages\ like\ C,\ just\ not\ the\ specification:\n\n======\n\ \ \ \ puts\ \"Sum\ of\ positive\ values:\ \[sum\ \[filter\ x\ \{\$x\ >\ 0.0\}\ \$data\]\]\"\n======\n\nor\ some\ such\ functionality.\n\nWell,\ enough\ explanation.\ Here\ is\ the\ program:\n\n======\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ #\ array_obj.tcl\ --\n#\ \ \ \ \ Use\ the\ ideas\ behind\ BLT's\ vector\ objects\ in\ a\ pure\ Tcl\ fashion:\n#\ \ \ \ \ -\ a\ Tcl\ array\ is\ backed\ up\ by\ \"private\"\ data\n#\ \ \ \ \ -\ the\ array\ syntax\ is\ used\ to\ access\ these\ data\n#\ \ \ \ \ -\ traces\ allow\ access\ to\ the\ actual\ data\n#\nproc\ mkarray\ \{name\ size\}\ \{\n\ \ \ \ global\ _\$name\n\ \ \ \ upvar\ 1\ \$name\ arrayName\n\n\ \ \ \ set\ _\$name\ \[lrepeat\ \$size\ 0\]\n\n\ \ \ \ trace\ add\ variable\ arrayName\ read\ \ readElement\n\ \ \ \ trace\ add\ variable\ arrayName\ write\ writeElement\n\}\n\nproc\ readElement\ \{arrayName\ element\ op\}\ \{\n\ \ \ \ global\ _\$arrayName\n\ \ \ \ upvar\ 1\ \$arrayName\ array\n\n\ \ \ \ if\ \{\ \[string\ first\ :\ \$element\]\ <\ 0\ \}\ \{\n\ \ \ \ \ \ \ \ set\ array(\$element)\ \[lindex\ \[set\ _\$arrayName\]\ \$element\]\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ regexp\ \{(\\d+):(\\d+)\}\ \$element\ =>\ first\ last\n\ \ \ \ \ \ \ \ set\ array(\$element)\ \[lrange\ \[set\ _\$arrayName\]\ \$first\ \$last\]\n\ \ \ \ \}\n\}\n\nproc\ writeElement\ \{arrayName\ element\ op\}\ \{\n\ \ \ \ global\ _\$arrayName\n\ \ \ \ upvar\ 1\ \$arrayName\ array\n\n\ \ \ \ if\ \{\ \[string\ first\ :\ \$element\]\ <\ 0\ \}\ \{\n\ \ \ \ \ \ \ \ lset\ _\$arrayName\ \$element\ \$array(\$element)\n\ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ regexp\ \{(\\d+):(\\d+)\}\ \$element\ =>\ first\ last\n\n\ \ \ \ \ \ \ \ incr\ first\ -1\n\ \ \ \ \ \ \ \ incr\ last\ \ \ 1\n\ \ \ \ \ \ \ \ if\ \{\ \[llength\ \$array(\$element)\]\ >\ 1\ \}\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ _\$arrayName\ \[concat\ \[lrange\ \[set\ _\$arrayName\]\ 0\ \$first\]\ \ \ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$array(\$element)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[lrange\ \[set\ _\$arrayName\]\ \$last\ end\]\]\n\ \ \ \ \ \ \ \ \}\ else\ \{\n\ \ \ \ \ \ \ \ \ \ \ \ set\ _\$arrayName\ \[concat\ \[lrange\ \ \[set\ _\$arrayName\]\ 0\ \$first\]\ \ \ \ \ \ \ \ \ \ \ \ \ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[lrepeat\ \[expr\ \{\$last-\$first-1\}\]\ \$array(\$element)\]\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[lrange\ \ \[set\ _\$arrayName\]\ \$last\ end\]\]\n\ \ \ \ \ \ \ \ \}\n\ \ \ \ \}\n\}\n\n#\n#\ Demonstrate\ the\ idea\ ...\n#\nmkarray\ x\ 100\n\nset\ x(1)\ 2\nputs\ \"x:\ \$x(1)\"\n\nset\ x(2:11)\ \{1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\ 10\}\nputs\ \$x(0:15)\n\nset\ x(0:4)\ 11\nputs\ \$x(0:15)\n\n#\ Now\ iterate\ over\ a\ part\ of\ the\ array\nset\ sum\ 0\nforeach\ v\ \$x(0:20)\ \{\n\ \ \ \ set\ sum\ \[expr\ \{\$sum\ +\ \$v**2\}\]\n\}\nputs\ \"Sum\ of\ squares:\ \$sum\"\n\n#\ Or:\nproc\ sum\ \{lambda\ list\}\ \{\n\ \ \ \ set\ result\ 0\n\ \ \ \ foreach\ item\ \$list\ \{\n\ \ \ \ \ \ \ \ set\ result\ \[expr\ \{\$result\ +\ \[apply\ \$lambda\ \$item\]\}\]\n\ \ \ \ \}\n\ \ \ \ return\ \$result\n\}\n\nputs\ \"Sum\ of\ squares:\ \[sum\ \{v\ \{expr\ \{\$v**2\}\}\}\ \$x(0:20)\]\"\n======\n\n<<categories>>\ \[Category\ Data\]|\[Category\ Mathematics\]} CALL {my revision {Using array syntax for, well, array manipulation}} CALL {::oo::Obj5315691 process revision/Using+array+syntax+for%2C+well%2C+array+manipulation} CALL {::oo::Obj5315689 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