Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: d326098e58421f2ffb4dd16e7b1974e83a776eb8
Ticket: 2200824fffffffffffffffffffffffffffffffff
awkward namespace behaviour
User & Date: cnassau on 2008-10-27 13:55:12
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    I've been playing around with the [otherwise wonderful] new oo package and stumbled across some namespace issues that I find rather inconvenient. 
    
    The following code works as it stands, but breaks if it is moved into a namespace:
    
        oo::class create fruit {}   
        oo::class create banana {
    superclass fruit
        }
    
    If this is evaluated in namespace mynsp the superclass statement needs to be changed:
    
      namespace eval mynsp {
        oo::class create fruit {}   
        oo::class create banana {
    # superclass fruit  ;# <- should work
            superclass mynsp::fruit  ;# does work
        }
      }
    
    I currently see no [non-convoluted] way to avoid the hardcoded reference to the mynsp-namespace in this superclass statement.
    
    The reason seems to be that oo::class evaluates its script in the oo::define namespace. Wouldn't it be better to extend the "namespace path" of oo::define during the execution of the definer script with the namespace path of the current namespace?
    
    Variable resolution is troubled by the same dilemma: the code 
    
      namespace eval mynsp {
        set bar baz
        oo::class create foo {
    method $bar args {}
        }
      }
    
    fails most of the time, because $bar currently resolves to $::bar rather than $mynsp::bar. 
    
    I would most humbly suggest to review these resolution rules again.
    
  4. foundin changed to: "obsolete: 8.6a3"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "cnassau"
  10. subsystem changed to: "35. TclOO Package"
  11. title changed to: "awkward namespace behaviour"
  12. type changed to: "Bug"