From: Andreas K. <and...@gm...> - 2024-09-24 19:02:40
|
> Op di 24 sep 2024 om 19:57 schreef Donald G Porter via Tcl-Core < > tcl...@li...>: > > > On 9/24/24 12:53, Andreas Kupries wrote: > > > I believe that I have found a bug in the `expr` command of > > > > > > Tcl 9 (commit <1f19a433ec>). > > > > This is a bad joke. > > > > > This behavior is caused by this commit: > <https://core.tcl-lang.org/tcl/info/a197811f135d262b> > and it's done on purpose. Read the ticket for the > reason behind it. It only happens when the value doesn't > match any other known type, so I don't see how it > can cause problems. Well, as I said in my initial mail, for extensions providing full-fledged Tcl_ObjTypes, i.e. full conversion to/from a string rep this is indeed not a problem. The next extension command will shimmer the value back to the type it wants. Just a bit of a performance-loss due to the additional shimmer. It is an issue for extensions using Tcl_ObjTypes without a string rep. These extensions usually do not try to shimmer from other types into theirs, and simply expect that the type coming in is as they expected. One of mine is such an extension (*, **), which is why I ran into the issue when I executed the test suite against a near-current Tcl 9 commit (3 days old) and got a load of test failures I knew had worked before with a commit from near the beginning of the year. I am willing to a accept the change, given the reasoning from the ticket, and given that I can change my code to detect the single-element list int.rep and then undo the wrapping to get at the actual and desired value. Given how I stumbled into this I would recommend and ask to place a note about this into the compatibility notes as something extension writers may have to be aware of. (*) https://core.tcl-lang.org/akupries/aktive/doc/trunk/README.md uses Tcl_Obj values to carry images. Which may be large. So I decided against dealing with a string rep which will not only materialize the entire block of pixels into memory, but worse, as some form of text. (**) The problematic `expr` is at https://core.tcl-lang.org/akupries/aktive/file?ci=trunk&name=op/embed.tcl& ln=58 and caught out at https://core.tcl-lang.org/akupries/aktive/file?ci=trunk&name=runtime/objty pe_image.c&ln=57 > From the ticket: > > A side-effect of this is that Tcl_GetNumberFromObj() now tries to > convert the object to a list, if it isn't already one of the > other known types (like dict, lseq, or index). That's very useful in > further error-handling, since the typePtr or lengthProc then > can be inspected for this case without trying to do more parsing. > > Hope this helps, Yes, very much, and thank you. -- Happy Tcling, Andreas Kupries <and...@gm...> <https://core.tcl-lang.org/akupries/> <https://akupries.tclers.tk/> Developer @ SUSE Software Solutions Germany GmbH ------------------------------------------------------------------------------- |