Skip to content
Tcl Source Code History Of Ticket 3304643
Login

History Of Ticket 3304643

Artifacts Associated With Ticket 3304643

  1. Ticket change [db3a0b512c] (rid 107923) by sehmann on 2011-05-19 15:04:21:

    1. assignee initialized to: "msofer"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Tcl8.4 would convert an object to a numeric type during execution of an operator (such as ==) when the other argument was of a numeric type.  It did not attempt to do this conversion if the other argument was "", a string, a user object type.
      
      Tcl8.5 now converts both arguments blindly when certain operators (such as ==) are executed.  This sometimes results in our objects (our own types) being converted and our internalRep being freed.  This causes a large portion of our TCL codebase to have a regression when one of our objects happens to have a string rep that is convertible to a int (eg. "123") or to a double (eg. "INF", "NAN", "0.5").  For example comparing "INF" == "" should not attempt convert both to numeric values.
      
      The fundamental problem is that there is no way to retain our object type information or avoid these conversions.  We key off the type to cast the internalRep pointer to our internal C++ object.  If this is not the best way to do cast to our internal object, please let us know the robustly supported way of doing that.
      
      Some solutions we see are:
      1) don't do the aggressive conversion (ie. go back to tcl8.4 style)
      2) only attempt numeric conversion if the type is one of the standard internal TCL types and not some user-specified type
      3) add a boolean to the TCL_Object which controls the immutability of an object (ie. don't do conversion if the flag is set)
      4) add a userdata field where we can store what we need (NULL or failure to recognize type stored in there means not our object)
      
      We need to be able to move forward with tcl8.5 and eventually tcl8.6 but this is holding us back.
      
    4. foundin initialized to: "obsolete: 8.5.9"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "sehmann"
    10. subsystem initialized to: "10. Objects"
    11. title initialized to:
      User object info lost on more aggressive numeric conversion
      
    12. type initialized to: "Bug"
  2. Ticket change [4737be2922] (rid 99659) by cjmcdonald on 2011-05-19 22:40:26:

    1. icomment:
      Or always use the "eq" operator to do string comparisons on your objects, instead
      of "==".
      
      For better or worse I use a similar scheme, storing a pointer to a C++ object in
      the Tcl object internalRep.  The only difference is that my object string reps
      never look like a numeric value, but I don't think that will be an issue anyway if
      you use "eq".  I haven't had many problems with Tcl 8.5, and the scheme has
      proved reliable.  The only issues have been:
      
      Losing internal rep converting between a list and a dict, which also affected
      array get/set.  This have been fixed in later 8.5.x releases.
      
      Overly aggressive conversions using %s in [format], which unfortunately
      also affects parray, so that listing the contents of an array loses any
      internal reps.  I think that this has been fixed in the Tcl 8.6 head.
      
      Otherwise all OK, although it will never be an officially approved or supported
      method, as using the internalRep in that way breaks the Tcl "Everything
      is a string" contract.  These object representations consist of a string AND
      some hidden state (the C++ object), which cannot be inferred just from the string.
      
      
    2. login: "cjmcdonald"
    3. mimetype: "text/plain"
    4. username: "cjmcdonald"
  3. Ticket change [6937f5ed7f] (rid 103211) by sehmann on 2011-06-28 21:10:22:

    1. foundin changed to: "obsolete: 8.5.10"
    2. icomment:
      Moving Group to a "current" one rather than an "obsolete" one in the hopes of getting more response.  Also bumping priority to 6 FWIW.
      
      Colin, always using "eq" is a good solution but is not going to work for us as we have lots of existing code and lots of developers who are never going to be able to remember these subtleties.
      
      Does anyone else have a comment?
      
      Generally not having a reliable model for our internal data causes us lost development time (not just on this issue) as we track down hard to understand Tcl internal workings.  It would be good to have a mode (such as my suggestion 3 or 4) so that we could be guaranteed data stability.  Basically there is one conversion policy and the data object provider cannot choose another one.
      
      Do we just have to live with the current conversion schemes?  Have any of my suggested solutions been discussed previously or in response to this?
      
      
    3. login: "sehmann"
    4. mimetype: "text/plain"
    5. priority changed to: "6"
    6. username: "sehmann"
  4. Ticket change [c70816c67f] (rid 121870) by dgp on 2011-06-30 03:20:07:

    1. icomment:
      
      My inclination is to say you are asking Tcl to
      do non-Tcl things.   But perhaps with a more
      detailed example I might find some middle
      ground of accommodation.  What's an example
      expression that illustrates the problem?  
      
      More examples and less description generally
      would be a better way for more people to understand
      the details of your troubles and either find a Tcl change
      to make you happy, or suggest changes to your code
      with the maximum pracitcality.
      
      When you create your own Tcl_ObjTypes, part of
      the contract with Tcl is that it can "re-type" values
      as it sees fit.  It will not change the value (assuming
      proper copy on write by everyone), but it might
      change the type.  The robust supported way to
      deal with that is for your Tcl_ObjType to supply a
      Tcl_SetFromAnyProc() that can take any Tcl string
      value and generate the corresponding internal
      rep your Tcl_ObjType uses.  That implies either
      encoding into the string rep all that needed to
      reconstruct your intrep, or using some kind of
      handle scheme with an auxilliary lookup (for
      example a hash table).
      
      That said, people have made other less robust
      schemes work, so please give a few examples
      so I can take a look at the details to see what
      solutions might be feasible.
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"