Skip to content
Tcl Source Code Artifact [6150e8d61c]
Login

Artifact [6150e8d61c]

Artifact 6150e8d61cfd1a34770a3243bbc6c1ef6b738b60:

Ticket change [6150e8d61c] - New ticket [1062849fffffffff|1062849fff] <i>EXPR with single substitution</i>. by alove on 2004-11-09 04:01:07.
D 2004-11-09T04:01:07
J assignee dkf
J cmimetype text/plain
J comment SUMMARY:\sThe\sEXPR\scommand\sin\sits\sregular\sform\s\nperforms\stwo\ssubstitutions:\sone\sby\sthe\sTcl\sparser\sand\s\none\sby\sthe\sEXPR\scommand\sitself.\s\sBut\sin\spractice,\sthe\s\nTCL\sparser\sis\srarely\sneeded;\salmost\sall\sEXPR\scommands\s\nare\scoded\swith\sdouble-braces\sto\simprove\sperformance.\s\s\nThis\sis\sa\smain\scontributor\sto\swhat\sis\sknown\sas\s"quoting\s\nhell"\swhen\susing\sTCL:\n\nset\svar\s[expr\s{$a*25}]\nset\sspeed\s[expr\s{($a+$b)/75}]\n\ncreate\sline\s[expr\s{$a+2}]\s[expr\s{$a2+7}]\s\\\n[expr\s{$a+$bh-2}]\s[expr\s{$b2+$a+3}]\s\n\nRather\sthan\susing\smore\squotes\sto\sgive\sa\ssingle\s\nsubstitution\sand\smore\sspeed,\sI\spropose\sa\snew\scommand\s\ncalled\sXP,\swhich\sis\sidentical\sto\sEXPR\swith\sdouble\sbraces.\s\s\nUsing\sthis\scommand,\sthe\sabove\scode\swould\slook\slike\sthis:\n\nset\svar\s[xp\s$a*25]\nset\sspeed\s[xp\s($a+$b)/75]\n\ncreate\sline\s[xp\s$a+2]\s[xp\s$a2+7]\s\\\n[xp\s$a+$bh-2]\s[xp\s$b2+$a+3]\s\n\nThe\sthird\sline\ssaves\s16\scharacters\sof\styping,\sincluding\s\neight\sdouble-braces\sthat\srequire\sthe\sshift\skey.\n\nIMPLEMENTATION:\sThis\scommand\swould\sbe\sidentical\sto\s\nEXPR\sexcept\sthat\sit\swould\sskip\sthe\sTCL\sparser.\s\sFor\s\ndemonstration,\syou\scan\ssimulate\sthe\scommand\s(but\snot\s\nits\sspeed)\susing\n\nproc\sxp\s{a}\s{\seval\sexpr\s{\s$a\s}\s}\s\n\n(This\sproc\sworks\sonly\sif\syou\sexclude\sspaces\sfrom\sthe\s\nexpression,\swhich\sis\swhy\sthe\sabove\sexamples\shave\sno\s\nspaces.)\n
J foundin None
J priority 5\sMedium
J resolution None
J status Open
J submitter alove
J subsystem 16.\sCommands\sA-H
J title EXPR\swith\ssingle\ssubstitution
J type RFE
K 1062849fffffffffffffffffffffffffffffffff
U alove
Z e384acff4567b5b596a70116d04dde58