Skip to content
Tcl Source Code History Of Ticket 3528418fffffffff
Login

History Of Ticket 3528418fffffffff

Artifacts Associated With Ticket 3528418fffffffff

  1. Ticket change [4a482409dd] (rid 126511) by lars_h on 2012-05-20 17:39:53:

    1. assignee initialized to: "msofer"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Today, I have encountered some curious details concerning the -map of [namespace ensemble]. The first thing, which is quite reasonable although a surprise to me as it does not seem to be mentioned in the manpage, is that all prefixes in the -map option will be made fully qualified whenever they are set. The second thing, which seems more questionable, is that they are always qualified using the current namespace rather than the namespace of the ensemble. The following modified test illustrates my expectation and the current outcome:
      
      
      ==== namespace-46.9 ensemble: configuring really configures things FAILED
      ==== Contents of test case:
      
          namespace eval ns {
      namespace ensemble create -map {a a} -prefixes 0
          }
          set result [list [catch {ns x} msg] $msg]
          lappend result [namespace ensemble configure ns -map] ; # Added
          namespace ensemble configure ns -map {b b}
          lappend result [catch {ns x} msg] $msg
          lappend result [namespace ensemble configure ns -map] ; # Added
          namespace delete ns
          set result
      
      ---- Result was:
      1 {unknown subcommand "x": must be a} {a ::ns::a} 1 {unknown subcommand "x": must be b} {b ::b}
      ---- Result should have been (exact matching):
      1 {unknown subcommand "x": must be a} {a ::ns::a} 1 {unknown subcommand "x": must be b} {b ::ns::b}
      ==== namespace-46.9 FAILED
      
      What seems wacky to me is that if I've created an ensemble using one value for -map, and then reconfigure it using the exact same value for -map (or perhaps more commonly some slight extension of same), then I will only get the same mapping of commands if I also issue the call from within the exact same namespace as I started with; I would rather expect that the -namespace namespace should be used, as it is for resolving -subcommands without an explicit -map entry.
      
      That said, I'm not sure that the behaviour is necessarily useless; I can see
      
        namespace ensemble configure $cmd -map [dict merge [namespace ensemble configure $cmd -map] {
            more  mappings
        }]
      
      being a potentially useful idiom for extending an ensemble with commands from a different namespace without having to fully qualify them explicitly, but whether it could be considered reliable behaviour is an open question: it's not mentioned in the manpage, and there does not seem to be any tests supporting that this is expected behaviour either.
      
      The practical cause of all this seems to be that TclNamespaceEnsembleCmd goes
      
          Namespace *nsPtr = (Namespace *) TclGetCurrentNamespace(interp);
      
      (tclEnsemble.c line 111) and takes this as specifying the namespace to operate in also for the ENS_CONFIG branch of the function. The subsequent check (lines 117--124)
      
          if (nsPtr == NULL || nsPtr->flags & NS_DYING) {
      if (!Tcl_InterpDeleted(interp)) {
          Tcl_AppendResult(interp,
          "tried to manipulate ensemble of deleted namespace",
          NULL);
      }
      return TCL_ERROR;
          }
      
      does however seem a bit out of place if nsPtr is always supposed to refer to the current interpreter namespace, so I'm inclined to hypothesise that this arose more out of accident than out of design.
      
      
    4. foundin initialized to: "obsolete: 8.6b2"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "lars_h"
    10. subsystem initialized to: "21. [namespace]"
    11. title initialized to: "ensemble namespace wackiness"
    12. type initialized to: "Bug"
  2. Ticket change [cb51c617be] (rid 95494) by msofer on 2012-05-21 00:57:08:

    1. assignee changed to: "dkf"
  3. Ticket change [2f2d92133a] (rid 93019) by dkf on 2012-05-21 23:00:25:

    1. icomment:
      Do you have a "tl;dr" version? Is this a functionality bug or documentation bug or what?
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  4. Ticket change [82d75fb5d3] (rid 117297) by lars_h on 2012-05-22 02:32:25:

    1. icomment:
      OK, shorter summary:
      
      1. When you [namespace ensemble configure -map] something, it fully qualifies the prefixes using the current namespace, not the -namespace of the ensemble. I think this is a *bug*.
      
      2. That prefixes are always stored fully qualified actually isn't mentioned in the manpage. I think it should be.
      
      
    2. login: "lars_h"
    3. mimetype: "text/plain"
    4. username: "lars_h"
  5. Ticket change [276fec7fb4] (rid 88516) by dkf on 2012-05-23 16:00:14:

    1. icomment:
      Re 1, that's _deliberate_. The names have to be qualified in order to get stable behavior anyway, and qualifying using the current namespace is the most flexible reasonable option. (You can use [namespace eval] to help select namespaces.)
      
      Re 2, OK, documentation needed.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  6. Ticket change [99a63f3b11] (rid 110828) by dkf on 2012-05-23 16:06:02:

    1. icomment:
      
      
      IP - Comment Removed: 130.88.1.31
      
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  7. Ticket change [1fb6b40ab8] (rid 91198) by dkf on 2012-05-25 21:53:56:

    1. closedate changed to: "2012-05-25T14:53:56"
    2. closer changed to: "dkf"
    3. icomment:
      
      
      allow_comments - 1
      
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "dkf"