.
D 2000-11-23T01:42:20
J assignee nobody
J cmimetype text/plain
J comment When\sprocessing\sthe\sUplevel\scommand,\sTCL\sneedlessly\srecreates\sthe\srelevant\scommand\s(the\sone\spassed\sas\san\sargument\sto\suplevel)\sfrom\sthe\sstring\srepresentation.\s\sHere\sare\sthe\sdetails:\n\nStart\sinteractive\stcl\sand\sgive\sthe\ssimple\scommand\s"put\s7".\sHere\s"put"\sis\sa\sunique\sprefix\sof\s"puts".\sThis\scauses\sus\sto\scall\sthe\sunknown\scommand,\swhich\seventually\scalls\s"uplevel\sputs\s7".\n\nIn\sTcl_UplevelObjCmd,\sline\s581\sof\stclProc.c,\swe\sset:\n\n\s\soptLevel\s=\sTclGetString(objv[1])\n\nThis\scall\sseems\sintended\sto\ssee\sif\sfirst\sargument,\sobjv[1],\sis\san\sinteger\sgiving\sthe\slevel\sto\suse.\s\sHowever,\sthe\ssyntax\sof\suplevel\sallows\sus\sto\somit\sthis\sargument,\sin\swhich\scase\sobjv[1]\sis\sactually\sa\slist\scontaining\sobjects\srepresenting\sthe\scommand\swe\swish\sto\sexecute.\sAs\sa\sside\seffect,\sthis\scall\ssets\sthe\sstring\srepresentation\sof\sthe\slist\sobject,\swhich\swill\sbe\ssignificant\slater.\n\nOn\sline\s604\swe\scall\sTcl_EvalObjEx,\spassing\sthe\slist\sobject\s(which\sis\snow\sobjv[0]\sas\sa\sresult\sof\sthe\sincrement\son\sline\s590,\swhere\sresult\swas\s0).\n\nIn\sTcl_EvalObjEx,\swe\sdecide\swhether\sto\sexecute\sthe\scommand\sand\sarguments\sas\sa\svector\sof\sTcl_Objs\s(line\s2575\sof\stclBasic.c)\sor\sby\sconverting\sthe\slist\sobject\sto\sa\sstring\sand\spassing\sthat\s(line\s2580).\sFor\ssome\sreason\s(perhaps\sa\sgood\sone,\sI\sdon't\sknow)\sif\sobjPtr\s(which\sis\sin\sthis\scase\sa\slist)\salready\shas\sa\sstring\srepresentation\swe\suse\sthat.\sThis\shappens\seven\sthough\sthe\sobject\srepresentation\sis\sperfectly\svalid.\n\nAs\sa\sresult,\swe\sneedlessly\sreinterpret\sthe\sstring.\n\nWhy\sis\sthis\sa\sproblem?\s\n\n1.\sInefficiency\sof\shaving\sto\sreinterpret\sthe\sstring.\n\n2.\sThere\smay\sbe\scases\swhere\sit\sis\simpossible\sto\sreconstruct\san\sinternal\srepresentation\sfrom\sa\sstring.\s\sThis\sis\smy\sreal\sconcern.\n\nConsider\sthe\scommon\scase\sof\san\sextension\smodule\swhich\sregisters\sits\sown\sTcl_TypeObj.\sThe\sinternal\srepresentation\sis\sa\spointer\sto\sa\sC++\sclass\sinstance\sand\sI\sdefine\sa\sfreeInternalRepProc\scallback\sto\sfree\smy\sinstance\swhen\sthe\sTcl_Obj's\sreference\scount\sgoes\sto\s0.\s\sI\scan\scertainly\sprovide\sa\sfunction\sto\sget\sa\sstring\srepresentation\sof\sthe\npointer\svalue.\sI\scan\salso\sreconstruct\sthe\spointer\svalue\sfrom\sthe\sstring\srep,\sbut\show\sdo\sI\sknow\sthat\sthe\sinstance\shasn't\sbeen\sdeleted\salready?\n\nDoes\sTCL\sreally\srequire\sthe\sability\sto\sreconstruct\san\sinternal\srep\sfrom\sa\sstring\s(for\sbetter\sreasons\sthan\sin\sthe\scase\sreported\sabove)?\sIf\sso,\swhere\sand\swhy?\n
J foundin obsolete:\s8.3.2
J priority 5\sMedium
J resolution None
J status Open
J submitter jgreene
J subsystem 81.\sBundled\sPackages
J title uplevel\sneedlessly\sreconstructs\sinternal\srep\sfrom\sstring
J type Bug
K 223217ffffffffffffffffffffffffffffffffff
U jgreene
Z eeac8cab90565911cf3bccf0b6f1053b