Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 4fa6445c7ea41617aefa323ea90efef4d03d7feefdab30ac08ec7c69594fda88
Ticket: 910d67a229fe7f653d28c00e470f2c256e3628ce
NS-qualified invocations of command evade [namespace unknown]
User & Date: sebres on 2024-03-06 12:50:12
Changes

  1. icomment:
    There is a small amend [98aab416a2bac6b0] for additional corner case (calling near-fully qualified command <code>foo::bar::xxx</code> from global NS).<br/>
    For some reason there is a deviation, depending on invocation type (compiled/direct/NRE), how <code>TEOV_NotFound</code> may get the command in <code>objv[0]</code>: as <code>::foo::bar::xxx</code> or as <code>foo::bar::xxx</code> (so with and without leading colons).<br/>
    This amend considers that and add still one corner case in test.
    
    To obtain real normalized command name inside the handler one would anyway use something like this (e. g. with auto_qualify like global ::unknown):
    <code><pre>
        # fully-qualified command name:
        lindex [auto_qualify $cmd [uplevel {namespace current}]] 0
        # fully-qualified command name (without auto_qualify):
        regsub -all {(::){2}} [uplevel {namespace current}]::$cmd {::}
        # relative command name:
        regsub {^(::){1,2}foo::bar(::){1,2}} [uplevel {namespace current}]::$cmd {}
    </pre></code>
    
    <i>(Suggestion, just as nice to have)</i><br/>
    For the last (to obtain normalized relative name) one could extend <code>[namespace tail]</code> like:
    <code><pre>
        % namespace tail 
        namespace tail string ?relative?
        % namespace tail ::foo::bar::xxx::yyy ::foo::bar
        xxx::yyy
    </pre></code>
    
  2. login: "sebres"
  3. mimetype: "text/x-fossil-wiki"