Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 04628d358eb4437962adfa3a2a08ac5ea1f5e897
Ticket: 1893052fffffffffffffffffffffffffffffffff
Object type info can be lost after comparison (e.g. INST_EQ)
User & Date: dgp on 2008-02-14 23:13:56
Changes

  1. closedate changed to: "2008-02-14T16:13:56"
  2. closer changed to: "dgp"
  3. icomment:
    Logged In: YES 
    user_id=80530
    Originator: NO
    
    
    Your error is in thinking about
    this as "type information".  That's
    not what it is.  Tcl values are untyped,
    or string typed if you prefer.  The
    internal rep is only a cache of the
    most recent conversion done so that
    if that same conversion is needed again
    (frequently the case) it need not be
    repeated.  The objPtr->typePtr indicates
    which kind of conversion has been cached;
    nothing more.
    
    From this perspective, your claim "there
    is no guarantee that the type conversion is
    reversible" is simply false.  The string value
    is the value.  If you can't do what you need
    with the string value alone (plus possibly some
    state you've arranged to associate with the interp),
    then at best you have an abuse of the Tcl_Obj system,
    which might work if you take special care and jump
    through some hoops, but isn't the supported model.
    
    One hoop you can jump through that will help avoid
    this issue is to craft string reps that are not
    valid values of other known Tcl_ObjTypes.
    
    Finally, back to your original post, it may well be
    that you can avoid the immediate problem by using the
    "eq" operator instead of the "==" operator:
    
    set a ...
    set b ...
    if {$a eq $b} {...}
    
    
    
  4. login: "dgp"
  5. mimetype: "text/plain"
  6. status changed to: "Closed"
  7. username: "dgp"