Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 1aa00b5b8f2c9ade752870517c2281a6e5c0f0fe
Ticket: 560297ffffffffffffffffffffffffffffffffff
[namespace forget] matches by name only
User & Date: dgp on 2004-08-31 23:18:22
Changes

  1. icomment:
    Logged In: YES 
    user_id=80530
    
    
    the failing test raises the question
    of how to forget import chains.
    
    % namespace eval origin {  
        namespace export cmd
        proc cmd args {}
    }
    % namespace eval link {
        namespace export cmd
        namespace import origin::cmd
    }
    % namespace eval unrelated {
        namespace export cmd
        proc cmd args {}
    }
    % namespace eval my namespace import ::link::cmd
    
    At this point, in an unpatched Tcl, any of
    the following commands in namespace "my"
    will forget my::cmd :
    
    namespace forget ::origin::cmd
    namespace forget ::link:::cmd
    namespace forget ::unrelated::cmd
    
    The last is case (1) in the bug report.
    
    After the attached patch is applied,
    only
    
    namespace forget ::origin::cmd
    
    will work.
    
    The test fails because it would
    expect that
    
    namespace forget ::link::cmd 
    
    would also work, and that has
    some intuitive appeal as well,
    as that is really the command
    that was imported.
    
    So we have some options
    how to deal with the links in
    an import chain:
    
    1) forget based only on the origin.
      - what the patch does
    2) forget based only on the first link
      - closer in intuition to being the
        inverse of a [namespace import]
    3) Both 1) and 2)
      - allow forgetting by either 1st or last
    4) forget based on any link in the chain at all
    
    Advantage of 1) is that it means
        [namespace forget [namespace origin $cmd]]
    is always a reliable operation.
    Advantage of including 2) as well is that
    there will be no failing tests, and it's
    more intuitive
    So, I think I like 3)
    
    Should probably be said that this whole
    realm is likely best avoided by using
    [namespace forget $simpleName]
    whenever possible.
    
    
    
  2. login: "dgp"
  3. mimetype: "text/plain"
  4. username: "dgp"