From: Brian G. <bgr...@mo...> - 2006-11-02 17:37:36
|
Larry McVoy wrote: > On Thu, Nov 02, 2006 at 04:24:21PM +0000, dr...@hw... wrote: > >> Brian Griffin <bgr...@mo...> wrote: >> >>> ABSTRACT >>> ========== >>> >>> This TIP proposes allowing unquoted words to be recognized as strings >>> in expressions (*expr*, *if*, *while*). >>> >>> >> I would much prefer that unquoted words be recognized as variable >> names. The single most common mistake I make when programming >> in TCL is to omit the $ before variable names in expr. >> I would attribute this kind of mistake to "thinking in C" rather then a short coming of Tcl. I also make the mistake of putting {} around if conditions in C, but I'm not going to petition the C standards body to accept {} in place of () because of my forgetfulness. > > I tend to agree. And while we're there, is there really any need to > preserve the fact that you can do > > set {silly variable name!} "some string" > > Wouldn't life be simpler if there was a > > tcp configure c-variable-names true > No, it wouldn't! Again, Tcl is not C! The point is that the current situation is inconsistent. set foo ASTRING ;# legal syntax set foo "ASTRING" ;# legal syntax if {$foo eq "ASTRING"} ;# legal syntax if {$foo eq ASTRING} ;# illegal syntax! This is odd and goes against the EIAS basis of Tcl. Either accept unquoted string in expressions or require quotes everywhere else in Tcl. A third option is to divorce expr from "if", "while", and "for" commands, replacing it with a more Tclish conditional expression evaluator. -Brian |