User talk:Dkf: Difference between revisions

(Fixed math.)
(→‎Question on Nan: new section)
Line 122:
 
Please don't edit user pages directly, even if they haven't created it yet. For something like that, I'd leave a friendly greeting and some advice in their user talk page. --[[User:Short Circuit|Michael Mol]] 16:30, 23 December 2009 (UTC)
 
== Question on Nan ==
 
One of the wonderful (or horrible - your call) properties of Tcl is that it is type-free. Or at least that's the way I understand it: everything is just strings of bytes; code, data, numbers, processes, text - at the bottom it's all just strings of bytes. Whether something is a "number" is an interpretation; <tt>"set a 5"</tt> creates a length-1 string containing the byte that can be interpreted as the ASCII symbol "5" or the number 5 (or any other way). So it would seem utterly natural to me to
 
<pre>
(Tcl) 1 % package require Tcl 8.5
8.5.8
(Tcl) 2 % set nan NaN
NaN
(Tcl) 3 % expr {$nan+0}
can't use non-numeric floating-point value as operand of "+"
</pre>
 
as opposed to, say
 
<pre>
(Tcl) 4 % set nan Booger
Booger
(Tcl) 5 % expr {$nan+0}
can't use non-numeric string as operand of "+"
</pre>
 
Because "NaN" can be interpreted as a number, while "Booger" has no such interpretation. (My 8-year old disagrees with this, by the way). I would maintain that <tt>"set nan NaN"</tt> does not only have the exact same outcome (generates the same result) as <tt>"binary scan [binary format q nan] q nan"</tt> but that it is actually more idiomatic, more Tcl'ish, more the way of "Tcl does what you expect".
Anonymous user