Artifacts Associated With Ticket 229fa65563
Ticket change [83b72afc7d] (rid 146898) by pooryorick on 2016-06-03 14:28:36:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- 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> - foundin initialized to: "8.6"
- is_private initialized to: "0"
- login: "pooryorick"
- priority initialized to: "5 Medium"
- private_contact initialized to: "a5d657bd6eb6e75747f01adab66e620d8b96868f"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "pooryorick"
- subsystem initialized to: "18. Commands M-Z"
- title initialized to: "tailcall inside apply inside namespace"
- type initialized to: "Bug"
Ticket change [70e9b7b80d] (rid 147126) by aspect on 2016-06-25 08:02:20:
- 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. - login: "aspect"
- mimetype: "text/plain"
- icomment:
Ticket change [5525d1bd72] (rid 147726) by dkf on 2016-07-09 08:48:24:
- closedate changed to: "2457578.86695532"
- closer changed to: "dkf"
- 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>
- login: "dkf"
- mimetype: "text/html"
- resolution changed to: "Wont Fix"
- status changed to: "Closed"
- subsystem changed to: "60. NRE and coroutines"
- username: "dkf"
Ticket change [942e360e6f] (rid 234240) by pooryorick on 2024-10-11 19:33:11:
- closedate changed to: "2460595.31471756"
- closer changed to: "pooryorick"
- login: "pooryorick"
- mimetype: "text/plain"
- resolution changed to: "Invalid"