| Ticket UUID: | 31fedb885e801f4cc41c7b1f4438e27ce4a3667 | ||
| Title: | Tcl_ExprLong documentation omission | ||
| Type: | Bug | Created on: | 2025-03-25 00:09:34 |
| Submitter: | emiliano | Assigned to: | nobody |
| Subsystem: | 69. Other | Severity: | Important |
| Priority: | 5 Medium | Last modified: | 2025-03-27 07:03:16 |
| Status: | Open | Closed by: | nobody |
| Resolution: | None | Closed on: | |
| Version: | trunk | ||
| Description: | ||||
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 ""
| ||||
| User Comments: | ||||
jan.nijtmans added on 2025-03-26 19:54:44:
In the code, I see this:
if (*exprstring == '\0') {
/*
* Legacy compatibility - return 0 for the zero-length string.
*/
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? apnadkarni added on 2025-03-27 02:51:59:
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. jan.nijtmans added on 2025-03-27 07:03:16:
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. | ||||
