3 ms·
> all values are (at least semantically) strings, so numeric operations are slow. All values are _still_ semantically strings (it's a core tenet of Tcl: "Every
by bch 10y ago
> all values are (at least semantically) strings, so numeric operations are slow.
All values are _still_ semantically strings (it's a core tenet of Tcl: "Everything is a string (EIAS)"), and in 1994, they were practically strings, too (that was the implementation). In 1999 w/ Tcl 8.0, Tcl became byte-compiled and adopted "Tcl_Obj" to represent values[0]. The Tcl_Obj (nothing to do w/ object-oriented programming), is what's called a "dual ported" object. It contains a string-representation of it's value (to preserve EIAS), and a "native" value of it's last computed use. For example, if you:
% set a 9.0
% expr { $a * 0.01 }
The native value of the Tcl_Obj $a refers to will be a float. Repeated calls to $a in a float-context will continue to use this already-computed native value. No need for further string interpolation.
[0] http://www.tcl.tk/software/tcltk/8.0.tml http://www.tcl.tk/software/tcltk/8.0.tml
[edit: formatting]