Overview
| Artifact ID: | 5ab639ab9220f7cb6b0717ccb264d584046811fa |
|---|---|
| Ticket: | 1489011fffffffffffffffffffffffffffffffff
mathfuncs return strings? numbers? |
| User & Date: | dgp on 2006-05-15 17:43:52 |
Changes
- assignee changed to: "kennykb"
- cmimetype changed to: "text/plain"
- comment changed to:
dgpIn Tcl 8.4, the only way to create a new math function is via Tcl_CreateMathFunc [13:17]dgpUsing that interface, the return type of the function had to be ont of the supported C types of the Tcl_Value struct. [13:18]dgpso mathfuncs were only good for computing numerical things [13:18]tclguyyes [13:18]dgpWith TIP 232 in place, that restriction is lifted... [13:20]dgp% proc tcl::mathfunc::append {args} { return [join $args ""] } % expr {append("foo","bar","soom")} foobarsoom [13:21]dgpIs this new ability an intended improvement? Or an unintended implementation consquence? [13:21]dkf_dgp: improvement [13:22]dkf_I don't know about "intended" though [13:22]dgpdon't judge too quickly... [13:23]dkf_What I can say is that I know how bad it was before, having tried to write new functions using that old API [13:23]dgp% expr {append("N","a","N")} domain error: argument not in valid range [13:24]dgpif the [expr] core is supposed to check for numeric-ness of the result of a function, then screening out NaN's might make sense. [13:24]dgpbut if we intend string functions to work, we need to stop doing that. [13:25]dkf_Earlier on, I said that NaN was "the screaming horror hiding in the space between the 1s and the 0s" and I meant it [13:26]spjuthTry: expr {append("0","x","AF")} [13:26]dgpsame interp: % expr {sqrt(-1)} NaN(7ffffffffffff) [13:26]dgpso either way, the HEAD is currently buggy/inconsistent [13:26]dkf_it's the cvtToNumeric opcode that's wacky [13:26]dgpbut I'd like to know my opinions about which way correctness lies aren't in gross conflict with others. [13:27]dgp% expr {append("0","x","AF")} 175 [13:30]dkf_What would fail if line tclCompExpr.c:260 was commented out? [13:30]dgpI'll test and find out... [13:30]dkf_since I think that's what is causing the problem [13:32]dgpwhy is that line inactive in the sqrt() example? [13:32]dkf_probably a buggy INST_TRY_CVT_TO_NUMERIC implementation [13:34]dgpdkf, mucho failures regarding string rep of numbers [13:34]dgp[expr] apparently is supposed to produce canonical string reps [13:35]dgp% expr 0x1 1 spjuthMight be that sqrt(-1) contains a unary minus operator, thus INST_TRY_ is skipped. - foundin changed to: "obsolete: 8.5a5"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "dgp"
- subsystem changed to: "47. Bytecode Compiler"
- title changed to: "mathfuncs return strings? numbers?"
- type changed to: "Bug"