: <i>expr comparison operator result does not follow the documentation</i> plus 6 other changes
by
.
D 2024-03-11T23:06:37.181
J closedate 2460381.46293034
J closer sebres
J icomment From\spoint\sof\sview\sof\sthe\sTcl-parser\sthe\stokens\s`"12"`\sand\s`12`\s(but\salso\s`{12}`)\sare\sthe\ssame.\sSee\s[Tcl\slanguage\ssyntax](https://tcl.tk/man/tcl/TclCmd/Tcl.htm)\sfor\sbasic\sdetails\show\sTcl-parser\sworks.\r\n\r\nThe\smentioned\sdocumentation\sclarifying\sonly\sthat\sthere\sis\sa\sfallback\soperation\swhich\swould\scompare\sthem\sas\sstring,\s**if\sone\sof\sthe\soperands\sis\snot\snumeric**.\r\nHowever\sby\sthe\soperators\slike\s`<`,\sit'd\salways\sprefer\snumeric\scomparison\s(no\smatter\swhether\sit\sis\senclosed\sin\squotes\sor\snot).\r\n\r\n\r\nSince\s8.7\s([TIP\s461](https://core.tcl-lang.org/tips/doc/trunk/tip/461.md)),\sthere\sis\sa\slot\sof\sother\soperators\swhich\salways\suse\sstring\scomparison.\r\n\r\nIn\sthis\scase:\r\n\r\n```\r\n%\sexpr\s{12\slt\s2}\r\n1\r\n%\sexpr\s{"12"\slt\s"2"}\r\n1\r\n%\sexpr\s{{12}\slt\s{2}}\r\n1\r\n```\r\n(again,\sno\smatter\sthey\sare\senclosed\sin\squotes\sor\snot).\r\n\r\nBefore\sthat\s(for\s8.5\sor\s8.6)\sthere\sare\sonly\stwo\sstring\scomparison\soperators\savailable\s-\s`eq`\sand\s`ne`,\sso\sone'd\suse\s`[string\scompare]`\seither.\r\n\r\nAnother\spossibility\swould\sbe\sto\suse\sthe\strick\swith\sstring-concatenation\sto\sword-tokens,\sin\sorder\sto\sforce\sstring\scomparison:\r\n\r\n```\r\n%\sset\sa\s12;\sset\sb\s2;\sexpr\s{$a\s<\s$b}\r\n0\r\n%\sset\sa\s12;\sset\sb\s2;\sexpr\s{"s$a"\s<\s"s$b"}\r\n1\r\n```
J login sebres
J mimetype text/x-markdown
J resolution Invalid
J status Closed
K aa69bce71e214872af462de3a3050a46eec61385
U sebres
Z 0646d154e72d298cb010d91449504343