Skip to content
Tcl Source Code History Of Ticket 229fa65563
Login

History Of Ticket 229fa65563

Artifacts Associated With Ticket 229fa65563

  1. Ticket change [83b72afc7d] (rid 146898) by pooryorick on 2016-06-03 14:28:36:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      In the following script, there are two identical <code>apply</code> commands.
      The one inside <code>namespace val n1 ...</code> succeeds, while the other one
      fails:
      
      <code><verbatim>
      namespace eval n1 {
          proc p2 {} {
              set name [lindex [info level 0] 0]
              set name [uplevel 1 [list ::namespace origin $name]]
          }
          puts [apply [list {} {tailcall p2} ::n1]]
      }
      
      puts [apply [list {} {tailcall p2} ::n1]]
      </verbatim></code>
      
      Error:
      
      <code><verbatim>
      invalid command name "p2"
          while executing
      "::namespace origin p2"
      ...
      </code></verbatim>
      
    5. foundin initialized to: "8.6"
    6. is_private initialized to: "0"
    7. login: "pooryorick"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "a5d657bd6eb6e75747f01adab66e620d8b96868f"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "pooryorick"
    14. subsystem initialized to: "18. Commands M-Z"
    15. title initialized to: "tailcall inside apply inside namespace"
    16. type initialized to: "Bug"
  2. Ticket change [70e9b7b80d] (rid 147126) by aspect on 2016-06-25 08:02:20:

    1. icomment:
      Isn't this expected?
      
      % namespace eval n0 {
          proc p0 {} {
              uplevel 1 {namespace current}
          }
      }
      % namespace eval n1 {
          puts [apply {{} {tailcall p0} ::n0}]
      }
      ::n1
      
      The lambda body evaluates in a level in ::n0.  [tailcall] looks up p0 in that context, finding ::n0::p0).  Then the apply's frame is discarded and replaced with a new call.
      
      Thus {uplevel 1} doesn't find ::n0 because that level no longer exists - level -1 is where [apply] was invoked.
      
      It's unfortunate that:
      
        [uplevel 1 [list ::namespace origin [lindex [info level 0] 0]]]
      
      can fail to find a qualified name when used in a procedure that has been tailcalled.  Prior to [tailcall], I believe this idiom was 100% reliable (?).
      
      If that is a significant loss, the only way I can see to restore it is if [tailcall] puts the fully-qualified name of the command on the stack .. but that might have other implications that break the utility of [lindex [info level 0] 0].  Meanwhile, I suspect [tailcall] already mixes badly with highly introspective procedures like this.
      
    2. login: "aspect"
    3. mimetype: "text/plain"
  3. Ticket change [5525d1bd72] (rid 147726) by dkf on 2016-07-09 08:48:24:

    1. closedate changed to: "2457578.86695532"
    2. closer changed to: "dkf"
    3. icomment:
      I'd also expect this to not work for those reasons; <tt>tailcall</tt> <i>replaces</i> a stack frame entirely by design, so anything that would have required the stack frame to be there (such as introspection) won't work.<p>If it is causing problems in a specific case, replace <tt>tailcall ...</tt> with <tt>return [uplevel 1 [list ...]]</tt>
      
    4. login: "dkf"
    5. mimetype: "text/html"
    6. resolution changed to: "Wont Fix"
    7. status changed to: "Closed"
    8. subsystem changed to: "60. NRE and coroutines"
    9. username: "dkf"
  4. Ticket change [942e360e6f] (rid 234240) by pooryorick on 2024-10-11 19:33:11:

    1. closedate changed to: "2460595.31471756"
    2. closer changed to: "pooryorick"
    3. login: "pooryorick"
    4. mimetype: "text/plain"
    5. resolution changed to: "Invalid"