Skip to content
Tcl Source Code Artifact [a6eeb13f71]
Login

Artifact [a6eeb13f71]

Artifact a6eeb13f71318e5a39edee84c722ad90cda3dc04:

Ticket change [a6eeb13f71] - New ticket [217782ffffffffff|217782ffff] <i>for loop with body &quot;puts $i&quot; does not compile correctly</i>. by nobody on 2000-10-26 00:43:34.
D 2000-10-26T00:43:34
J assignee nobody
J cmimetype text/plain
J comment OriginalBugID:\s727\sBug\nVersion:\s8.0.3\nSubmitDate:\s'1998-10-13'\nLastModified:\s'1999-08-13'\nSeverity:\sSER\nStatus:\sClosed\nSubmitter:\sadmin\nChangedBy:\shobbs\nRelatedBugIDs:\s1669\nOS:\sAll\nOSVersion:\sNA\nMachine:\sNA\nFixedDate:\s'2000-10-25'\nFixedInVersion:\sNA\nClosedDate:\s'1999-08-13'\n\n\n"Jeffrey\sP.\sTalberg"\swrote:\n>\s\n>\sI\swas\strying\sto\screate\sa\ssimple\stcl\sexample\sthat\sI\scan\suse\sfor\steaching\n>\sa\scourse\sillustrating\sthe\sdifference\sbetween\s""\sand\s{}\sgrouping\sby\susing\n>\sthe\sfor\scommand\s.\n[snip]\n>\s#-----------------------------------------\n>\s#\sThis\sis\sthe\sone\sI\shad\sa\squestion\sabout\n>\s#-----------------------------------------\n>\sfor\s{set\si\s0}\s{$i\s<\s10}\s{incr\si}\s"puts\s$i"\n>\s\n>\sWhy\sdoes\sthe\slast\sversion\sstill\sprint\sthe\snumbers\s0-9?\s\sI\sexpected\sit\sto\n>\sprint\s0\s10\stimes.\s\sI\sthought\sthe\sstatement\s"puts\s$i"\swould\sbecome\s"puts\n>\s0"\swhen\sthe\sfor\scommand\sunderwent\sgrouping\sand\ssubstitution\sprior\sto\n>\scommand\sdispatch.\n\nYou\sare\scorrect,\sthat's\swhat\sit\sshould\sdo.\n\n>\s\n>\sI\swas\sintrigued\sby\sthese\sresults,\scan\sanyone\sexplain\swhy\stcl\sbehaves\n>\sthis\sway?\n\nThat\ssure\slooks\slike\sa\sbug\sto\sme.\sProbably\sour\sfriend\sthe\sbyte\scompiler\ndoing\ssome\s"optimizations"\sfor\sus.\s\n\nThis\shas\sprompted\sme,\sfinally,\sto\sreinstall\stcl\s7.6.\sIt\sseems\slike\sthere\nare\slots\sof\slittle\sbugaboos\spopping\sup\sthat\sseem\sto\sbe\srelated\sto\sthe\nbyte\scompiler.\sSure\senough,\srunning\sthis\sexample\swith\s7.6\sgives\sthe\nexpected\sresults:\n\n\s\s\s\s%\sfor\s{set\si\s0}\s{$i\s<\s10}\s{incr\si}\s"puts\s$i"\n\s\s\s\scan't\sread\s"i":\sno\ssuch\svariable\n\s\s\s\s%\sset\si\s0\n\s\s\s\s0\n\s\s\s\s%\sfor\s{set\si\s0}\s{$i\s<\s10}\s{incr\si}\s"puts\s$i"\n\s\s\s\s0\n\s\s\s\s0\n\s\s\s\s0\n\s\s\s\s...\n\nFWIW,\sI\scan\sduplicate\sthe\sbehavior\syou\sreport\swith\sboth\s8.0.3\sand\s8.1a2\nand\sprotclsh.\sInterestingly,\s\snot\sonly\sdoes\sthe\sloop\sperform\swrong,\sbut\nthe\sinterpreter\sdoesn't\sseem\sto\scare\sthat\s$i\sisn't\sdefined\sduring\sthe\nparsing\sphase.\sIt\slooks\slike\sthe\sbyte\scompiler\sis\sjust\sassuming\sthe\sbody\nshouldn't\sgo\sthrough\ssubstitution\sregardless\sof\sthe\squoting\s(shame\son\nit!).\s\n\nAs\sproof,\smodifying\sthe\scode\sto\sbe\sthis:\n\n\s\s\s\sfor\s{set\si\s0}\s{$i\s<\s10}\s{incr\si}\s[list\sputs\s$i]\n\n...\sgives\sthe\ssame\s(broken)\sresults.\sInterestingly,\sthis\sonly\sseems\sto\nhappen\sif\sthe\svariable\sin\sthe\sprint\sstatement\sis\sthe\ssame\sas\sthe\sloop\nvariable.\sFor\sexample,\sif\sI\schange\sthe\scommand\sto\sbe\s"puts\s$z"\sI\sget\sthe\nexpected\serror\smessage\s"can't\sread\s"z":\sno\ssuch\svariable".\s\n\n\nThis\sstill\sexists\sin\s8.2b3.\s\sSee\srelated\s1669\sfor\sdetailed\sevaluation.\s\n--\s08/13/1999\shobbs
J foundin obsolete:\s8.0.3
J priority 5\sMedium
J resolution None
J status Open
J submitter nobody
J subsystem 10.\sObjects
J title for\sloop\swith\sbody\s"puts\s$i"\sdoes\snot\scompile\scorrectly
J type Bug
K 217782ffffffffffffffffffffffffffffffffff
U nobody
Z 6f54ba5196ff6462387634a6590e7085