Skip to content
Tcl Source Code Artifact [8a12fc8acb]
Login

Artifact [8a12fc8acb]

Artifact 8a12fc8acb8b67cb7bdedc540d8cf57c8cfb1a96:

Ticket change [8a12fc8acb] - New ticket [781929ffffffffff|781929ffff] <i>[lexpand] expand-in-place command</i>. by muonics on 2003-08-02 11:32:36.
D 2003-08-02T11:32:36
J assignee msofer
J cmimetype text/plain
J comment This\srelatively\ssimple\spatch\sto\sTcl\s8.4.4\sadds\sa\snew\n"lexpand"\scommand\sto\sthe\score\sfor\sexpanding\slists\s"in\nplace"\sduring\sevaluation.\s\sIt\sis\ssuggested\sas\san\nalternative\sto\sthe\sproposed\s{}\sprefix\ssyntax\sconvention\ndescribed\sby\sTIP\s#144.\s\s"lexpand"\swas\schosen\sinstead\sof\n"expand"\sbecause\sUnix\ssystems\stend\sto\shave\san\s"expand"\ncommand,\swhich\smight\sbe\smore\slikely\sto\scause\nsilent-but-erroneous\sbehavior\sruning\sscripts\susing\sthe\nnew\scommand\sin\solder\sversions\sof\sTcl\s(this\sway\sit's\nmore\slikely\sto\sgive\san\s"unknown\scommand"\serror\sthan\sdo\nsomething\sincorrect\swith\sthe\sarguments).\s\sUsage:\n\nlexpand\s?list\s...?\n\nThe\spatch\sadds\sa\snew\sTcl_Obj\stype\sthat\sis\sjust\sa\nrenamed\slist\sobject\sfor\spurposes\sof\sflagging\sthe\sobject\nas\srequiring\sexpansion.\sThe\scommand\stakes\szero\sor\smore\narguments\sand\sreturns\sa\slist\sobject\sconsisting\sof\sthose\narguments\sbut\swith\sthe\snew\sobject\stype.\n\nTclEvalObjvInternal()\sis\smodified\sto\srecognize\sthis\ntype\sand\sreconstruct\sthe\sobjv\sarray,\sexpanding\sany\nelements\sof\sthe\snew\stype\sinto\sseparate\sarguments\sbefore\nlooking\sup\sand\scalling\sthe\scommand.\n\nlexpand\saccepts\smultiple\sarguments\sso\sthat\sit\scan\sbe\nnested\sfor\smultiple\slevels\sof\sexpansion.\s\se.g.\n\ncommand\s[lexpand\s[lexpand\s$args]]\n\nIt\scan\salso\sbe\sused\sto\sexecute\slist\svariables\sdirectly\n(similar\sto\seval):\n\n[expand\s$script]\n\nIt\scannot,\sof\scourse,\sbe\sused\swith\s"set"\sunless\sthe\nexpansion\sresults\sin\sa\ssingle\selement\sresult:\n\nset\sx\s[list\sa\sb\sc\sd\se]\nset\sy\s[expand\s$x]\n\n...will\sresult\sin\san\serror\sbecause\sit\sis\sequivalent\sto...\n\nset\sy\sa\sb\sc\sd\se\n\nLikewise,\syou\scannot\sreturn\s[expand\s$list],\sunless\n$list\smatches\sthe\sallowed\soptions,\sreturn\scodes,\setc.\nfor\sreturn.\s\sIn\sother\swords,\sI\sguess\syou\scould\ssay\sthat\nthe\snew\sTcl_Obj\stype\sis\snot\sa\sfirst-class\sobject,\swhich\nis\sessentially\sthe\sintent\sof\sexpansion\sin\splace.\n\nOne\scaveat:\sno\sassumption\sis\smade\sin\sthis\sversion\sof\nthe\spatch\sas\sto\swhether\sempty\slist\selements\sshould\sbe\ndiscarded.\s\sThat\sis...\n\n[expand\s$script]\n\n..is\snot\sthe\ssame\sas...\n\neval\s$script\n\n...\sif\s$script\scontains\sempty\sstrings\sor\slists.\s\se.g.\n\nset\sscript\s[list\sputs\s""]\n[expand\s$script]\s\s=>\s\sputs\s""\neval\s$script\s=>\sputs\n\nHowever,\sit\scould\sbe\swith\svery\sminor\schanges\s(just\nbuild\sthe\sresult\selement-by-element\sin\nTcl_LexpandObjCmd()\srather\sthan\scalling\nTcl_NewListObj()\swith\sthe\sfull\sset\sof\sarguments).\s\nPerhaps\sthe\sbehavior\scould\sbe\smade\san\soption.\s\sBut\sI\nwasn't\scertain\swhich\sbehavior\speople\sexpect/desire.\n\nMy\shope\sis\sthat\sthis\swill\smake\sthe\s{}\ssyntax\nunnecessary,\sbut\sI\sbelieve\sthat\sit\swould\sbe\sextremely\neasy\sto\ssupport\sboth\sforms\sif\sdesired\sor\suse\sthis\scode\nas\sthe\sbasis\sfor\s{}\sif\s(unfortunately)\sthat\ssyntax\sis\nchosen\sover\s[lexpand].\n\nOh,\sand\splease\scheck\sto\smake\ssure\sthere\saren't\sany\nreference\scounting\sissues!\s:)
J foundin None
J priority 5\sMedium
J resolution None
J status Open
J submitter muonics
J subsystem 45.\sParsing\sand\sEval
J title [lexpand]\sexpand-in-place\scommand
J type Patch
K 781929ffffffffffffffffffffffffffffffffff
U muonics
Z 290af1396e85e79a8d8843835caeee70