|
From: Don P. <dg...@ca...> - 2000-10-03 19:32:40
|
According to Don Porter <dg...@ca...>:
>: I recommend that Tcl's configure script also test
>: for the presence of a C9X strtod(), and replace it with the
>: compat/strtod.c version as well.
<lv...@ca...> wrote:
> It sure is a shame to put yet another road block in the way of international
> standards by replacing standard C behavior with a subset of that behavior.
I'm afraid I don't see the force of your argument. Certainly the
developers of C libraries should implement C libraries that conform
to the international standards for C libraries. What does that
(necessarily) have to do with what interface current and future
releases of Tcl should support?
> Wouldn't we rather see the compat/strtod.c upgraded to take the new format,
> instead of telling people though they can use such numbers with perl, python,
> etc. they are not permitted to use them with tcl?
That's certainly another way we can go. What's not acceptable is the
status quo where [string is double] and [expr] disagree about what is
a valid floating point number, and where an [lsort] can change the
result of a comparison:
% set a 1.5
1.5
% set b 0x1.8p0
0x1.8p0
% expr {$a == $b}
0
% lsort -real [list $a $b]
1.5 0x1.8p0
% expr {$a == $b}
1
% expr {$a + 0}
1.5
% expr {$b + 0}
can't use non-numeric string as operand of "+"
% string is double $a
1
% string is double $b
1
Besides, if we decide that Tcl should recognize hexadecimal floating
constants, that should be a conscious, explicit, and documented
decision about the Tcl interface, and it should be implemented
cross-platform. It should not be an accidental consequence of what
C library Tcl happened to be compiled with.
Also, unlike C libraries, Tcl libraries have version numbers which
are accessible to their callers, and conventions about what version
numbers can include incompatible changes. If we decide that Tcl
should support hexadecimal floating constants, that support ought
to take effect with a new major release of Tcl.
Currently [expr] documents its recognition of floating-point
values:
...Floating-point numbers
may be specified in any of the ways accepted by an ANSI-
compliant C compiler (except that the f, F, l, and L suf
fixes will not be permitted in most installations). For
example, all of the following are valid floating-point
numbers: 2.1, 3., 6e4, 7.91e+16. ...
Note "ANSI-compliant", not "ISO C9X-compliant". That is in fact
what [expr] does. [lsort -real], [string is double], etc. are
inconsistent with that. I think that's a bug.
--
| Don Porter Mathematical and Computational Sciences Division |
| don...@ni... Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|
--
The TclCore mailing list is sponsored by Ajuba Solutions
To unsubscribe: email tcl...@aj... with the
word UNSUBSCRIBE as the subject.
|