<i>Regression with TIP #636 in foreach</i> status still Open with 3 other changes
by
.
D 2023-07-12T05:46:40.808
J icomment Adding\smy\stwo\scents,\smore\sto\sclarify\smy\sown\sthinking:\r\n\r\n*\sTcl\svalues\sare\sdefined\sby\stheir\sstring\srepresentation\sas\sstored\sin\sthe\s`Tcl_Obj.bytes`\sfield\r\n\r\n*\s`Tcl_DuplicateObj`\spreserves\sthe\svalue\ssematics\sby\spreserving\sthe\s`bytes`,\swhile\s`TclDuplicatePureObj`\sdoes\snot.\sConsider\stwo\sobjects,\sboth\sof\stype\s`intType`\s(or\swhatever\sthe\s`int`\sinternal\srep\sis)\swith\svalue\s16\sbut\s`obj1.bytes`\sbeing\s"16"\sand\s`obj2.bytes`\sbeing\s"0x10".\sThese\sare\snot\sequal\svalues\sbut\s`obj1`\sand\s`TclDuplicatePureObj(obj2)`\swill\sbe\sequal.\r\n\r\n*\s`Tcl_DuplicateObj`\swas\sused\sin\sat\sleast\stwo\sways.\sOne\swas\sto\smake\san\sunshared\scopy\sfor\sfurther\smodification.\sThe\sother\swas\sto\sensure\sthe\sinternal\srep\sremained\svalid\s(e.g.\siterating\sa\slist)\seven\sthough\sno\smodification\swas\splanned.\s`TclDuplicatePureObj`\scan\sreplace\s`Tcl_DuplicateObj`\sin\sthe\sfirst\sinstance\ssince\sanyways\sthe\s`bytes`\swill\sbe\sinvalidated.\sI\sdon't\sthink\sit\scan\sreplace\sin\sthe\ssecond\sinstance.\sAll\suses\sneed\sto\sbe\sexamined\sfor\swhich\sof\sthe\stwo\scases\sapplies.\r\n\r\n*\sI\sam\sa\sbit\suncomfortable\swith\sthe\simplementation\swhich\scopies\sthe\s`bytes`\spointer\sfrom\sthe\ssource\sto\sthe\sdup\sobject\sand\scalls\s`Tcl_ConvertToType`.\sI\sdon't\sknow\sif\sthere\sare\sany\sguarantees\sthat\s`Tcl_ConvertToType`\swill\snot\ssomehow\smanipulate\sthe\sallocation\sif\sthe\sTcl_Obj\sis\sunshared.\sMay\snot\sbe\sa\sproblem\snow\sbut\sin\sthe\sfuture\sfor\sall\spossible\stypes?\r\n\r\n*\sAlthough\sI\sinitially\sthought\sthe\soption\stable\scode\smight\salso\sviolate\sconsistency,\sI\sam\snot\sso\ssure\sany\smore\sbased\son\smy\s`int`\sexample\sabove.\sIt\sis\slegitimate\sto\shave\stwo\sstring\svalues\smap\sto\sthe\ssame\sinternal\srep.\sHowever,\swhen\sgenerated\sfrom\sa\sstring,\sthe\sstring\srepresentation\s*must*\sbe\spreserved.\sThis\sdoes\snot\shappen\sdue\sto\s`TclDuplicatePureObj`,\snot\sbecause\sof\sthe\soption\stable\scode.
J login apnadkarni
J mimetype text/x-markdown
K a34733451b2cf189528061944466cf7ce7015008
U apnadkarni
Z a7c80aa25da2e1f79eb332a4e9d4f7a5