Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b3048b044566a4f8aff866b55f049fcc419a18c8
Ticket: 752814ffffffffffffffffffffffffffffffffff
Inhibit some type conversions
User & Date: ysutjandra on 2003-06-12 05:20:52
Changes

  1. icomment:
    Logged In: YES 
    user_id=799156
    
    I'm sorry I said the wrong thing.
    
    I said..
       At the very least, it should check whether the Tcl_Obj is 
       shared or not, and create a utf-8 string object on a new 
       Tcl_obj.
    
    I meant to say,
    
       At the very least, it should check whether the Tcl_Obj is 
       shared or not, and create a unicode string object on a new 
       Tcl_obj.
    
    
    I guess it's fine if it's a requirement that regexp will change 
    any object type to a string.  I understand from your 
    explanation that the regexp has to operate on an object with 
    unicode type, leading to converting the old representation (of 
    the type I registered) to the unicode representation and leads 
    to freeing the old representation.  
    
    
    I am trying to make use of Tcl memory management on 
    Tcl_Obj by registering my own object type so that it will call 
    the registered free function once it knows the object is not 
    needed anymore.
    
    In other words, I registered a new object-type, and I want 
    the Tcl_Obj that holds my object to stay as is throughout its 
    lifespan.  ie. it will only call the free function when the 
    refCount is zero.
    
    Now I want to stop users from executing commands that will 
    convert the object of my type to something else.  Probably 
    something like:
    
       set a [newMyType]
       regexp {hello} $a
       --> Illegal operation on variable a, 
       --> converting 'MyType' to 'string' is prohibited
    
       incr a
       --> Illegal operation on variable a,
       --> converting 'MyType' to 'int' is prohibited
    
    Currently, I know only how to detect this by implementing a 
    free function that detects whether the refCount is already 
    zero or not.  But this function returns void and I cannot stop 
    the users from doing this.
    
    I'm okay if there is a way to prevent users from using such 
    commands on my obj.  Is there a way to return an error at a 
    situation like this now.
    
    
    
    
  2. login: "ysutjandra"
  3. mimetype: "text/plain"
  4. username: "ysutjandra"