Jump to content

Talk:Arithmetic evaluation: Difference between revisions

New section: [[Talk:Arithmetic Evaluator#TCL and [expr]|TCL and [expr]]]
No edit summary
(New section: [[Talk:Arithmetic Evaluator#TCL and [expr]|TCL and [expr]]])
Line 1:
Should we assume clean input or do we need to add in error checking? --[[User:Mwn3d|Mwn3d]] 14:17, 11 December 2007 (MST)
:Left unspecified (a solution can do either) [[User:Epsilon]]
 
== TCL and [expr] ==
 
As is is written, this task is impossible in TCL since TCL has no concept of a "number" -- all variables are strings of bytes at the bottom and the only way to add a number to another one is to expressly declare some string to be interpreted as ... an expression. I.e. if variable "A" contains the string "3" then TCL has no idea that this might be a number. However [expr $A] would be a number (returned as a string again) and [expr $A+3] would be the string "6". Thus no matter how complicated my program might get, at some point I would <i>have to</i> invoke something like [expr $var1 $symbol $var2] (which would take the string formed by concatenating the contents of $var1, $symbol and $var2 and interpret them as an expression and return the result). This "bottom invocation", however would be prohibited by the task rules (and if I allow [expr] then I might as well just call [expr $original_string] and be done with the whole exercise in one line). Suggestions anybody? [[User:Sgeier|Sgeier]] 20:01, 22 January 2008 (MST)
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.