|
2025-03-27
| ||
| 07:03 | • Ticket [31fedb885e] Tcl_ExprLong documentation omission status still Open wi... artifact: d7e7e26cf2 user: jan.nijtmans | |
| 02:51 | • Ticket [31fedb885e]: 3 changes artifact: ce90df7b29 user: apnadkarni | |
|
2025-03-26
| ||
| 19:54 | • Ticket [31fedb885e]: 3 changes artifact: 04a31b4f0a user: jan.nijtmans | |
|
2025-03-25
| ||
| 00:09 | • New ticket [31fedb885e]. artifact: 1a8b5f0699 user: emiliano | |
Tcl_ExprLong documentation omission
The man page documenting the Tcl functions Tcl_ExprLong(), Tcl_ExprDouble(), Tcl_ExprBoolean() and Tcl_ExprString() omits to mention that these four functions returns TCL_OK and write a zero in the passed in variable if an empty string is provided (*expr == '\0').
This is relevant since evaluating an empty string in Tcl results in a different result.
$ tclsh9.1
% expr {}
empty expression
in expression ""
In the code, I see this:
if (*exprstring == '\0') {
/*
* Legacy compatibility - return 0 for the zero-length string.
*/
*ptr = 0;
} else {
This tells me that this behavior was not intended, but kept for compatibility with old versions of Tcl.
Wouldn't it be better to fix this behavior, generating an error-message in this case?
While I too would prefer fixing this as opposed to changing the documentation, I fear that opportunity might have passed with 9.0 release depending on whether one believes manpages are authoritative or the actual implementation.
Also, Tcl_ExprLongObj etc. may also have the same issue though I have not checked the actual behavior in those cases.
Or ... just deprecate those functions in 9.1 and remove them in 9.2. Or ... deprecate those in 9.0 and remove them in 9.1 ....
I only found 2 extensions still using any of those: Blt and Tix.
> Also, Tcl_ExprLongObj etc. may also have the same issue though I have not checked the actual behavior in those cases.
No, the *Obj() functions are OK, they - correctly - output an error-message in this case.