Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d9649e06af45f5c22d99f53946bafed6e5b9ebae
Ticket: 4af2f209f29c3d12e7302780135cbcb907234acb
oo::define variable
User & Date: aspect on 2016-01-17 13:43:45
Changes

  1. icomment:
    Playing around with this a little further, the quirk seems to be in how variables behave that are added to a class while a method is running.
    
    oo::class create D {
        method a {} {
            oo::define [self class] variable var
            puts [namespace which -variable var]\t[incr var]
        }
    }
    
    D create b
    b a
    # ::oo::Obj12::var        1
    b a
    # ::oo::Obj12::var        1
    b a
    # ::oo::Obj12::var        2
    
    
    According to [namespace which] and [info vars], $var immediately refers to the instance variable.  But that wasn't the case when the first call to [b a] was entered, so (it seems) incrScalar1Imm hits a local.
    
    Inhibiting compilation of [incr var] changes the behaviour -- TclIncrObj finds the instance variable each time.
    
  2. login: "aspect"
  3. mimetype: "text/plain"
  4. username: "aspect"