Artifacts Associated With Ticket 1017884fffffffffffffffffffffffffffffffff
Ticket change [ffa8f2882d] (rid 108787) by dvrsn on 2004-08-27 20:58:44:
- assignee initialized to: "msofer"
- cmimetype initialized to: "text/plain"
- comment initialized to:
uplevel always converts its first argument into a string in order to check if it is the optional ?level? argument. If the optional argument is not present, the first argument is converted anyway, which can take significant time and loses the benefit of direct list evaluation. set l [list] for {set c 0} {$c < 10000} {incr c} { lappend l 12345 } proc t1 {l} { set cmd [list llength $l] uplevel $cmd } proc t2 {l} { set cmd [list llength $l] uplevel 1 $cmd } puts [time {t1 $l} 100] puts [time {t2 $l} 100] - foundin initialized to: "None"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "dvrsn"
- subsystem initialized to: "22. [proc] and [uplevel]"
- title initialized to: "uplevel can shimmer to string unnecessarily"
- type initialized to: "RFE"
Ticket change [7cd415845f] (rid 97144) by msofer on 2004-08-28 04:14:06:
- icomment:
Logged In: YES user_id=148712 My first reaction to this is: always specify the level, do not rely on the default! My second reaction is: how do you think this could be fixed? One idea is to assume that, if there is just one argument to uplevel and it is a pure list, it has to be a script and we could avoid parsing it. But then the following script would have a different behaviour: % proc 1 {} {puts hi} % proc a {} {uplevel [list 1]} % a wrong # args: should be "uplevel ?level? command ?arg ...?" So now the question is: is this just a performance bug, or a real bug? Ie, should that script print "hi" or return an error as it does now? - login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [dbfec69aee] (rid 108055) by dgp on 2004-08-28 04:29:24:
- icomment:
Logged In: YES user_id=80530 The docs indicate that [uplevel 1] ought to be equivalent to [uplevel 1 1] It doesn't appear to be true. Looks like a bug to me. Either the docs or the code needs correcting. In practical terms. one should always provide an explicit level argument to [uplevel] and avoid any ambiguity or inefficiency.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [b7816b512a] (rid 125610) by msofer on 2004-08-28 05:30:55:
- closedate changed to: "2004-08-27T22:30:55"
- closer changed to: "msofer"
- icomment:
Logged In: YES user_id=148712 dgp later noticed that the docs say that [uplevel 1] is a syntax error: "Level cannot be defaulted if the first command argument starts with a digit or #." So: when there is a single argument, its string rep has to be examined to check that id does not start with a digit or #. The present behaviour is mandated by the docs.
- login: "msofer"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Closed"
- username: "msofer"
Ticket change [48416cb054] (rid 99853) by msofer on 2004-08-28 05:35:00:
- assignee changed to: "nobody"
- icomment:
Logged In: YES user_id=148712 Keeping this as an RFE for making the level argument mandatory, both for the performance reasons cited here and to avoid possible confusion. As a first step, the docs could state that omitting the 'level' argument is deprecated.
- login: "msofer"
- mimetype: "text/plain"
- resolution changed to: "None"
- status changed to: "Open"
- subsystem changed to: "None"
- title changed to: "make 'level' arg to uplevel/upvar mandatory"
- username: "msofer"
Ticket change [3cf531f34d] (rid 121003) by msofer on 2004-08-28 05:36:16:
- assignee changed to: "msofer"
- subsystem changed to: "22. [proc] and [uplevel]"
Ticket change [da66d8c5df] (rid 107777) by hobbs on 2005-05-31 08:53:41:
- closedate changed to: "2005-05-31T01:53:41"
- closer changed to: "hobbs"
- icomment:
Logged In: YES user_id=72656 Rejecting this request as impractical due to incompatability. You can file for a doc clarification, but you can't just break existing code.
- login: "hobbs"
- mimetype: "text/plain"
- resolution changed to: "Wont Fix"
- status changed to: "Closed"
- username: "hobbs"
Ticket change [57c85fd351] (rid 186859) by pooryorick on 2020-09-19 15:08:20:
- closedate changed to: "2459112.13078874"
- closer changed to: "pooryorick"
- comment changed to:
uplevel always converts its first argument into a string in order to check if it is the optional ?level? argument. If the optional argument is not present, the first argument is converted anyway, which can take significant time and loses the benefit of direct list evaluation. set l [list] for {set c 0} {$c < 10000} {incr c} { lappend l 12345 } proc t1 {l} { set cmd [list llength $l] uplevel $cmd } proc t2 {l} { set cmd [list llength $l] uplevel 1 $cmd } puts [time {t1 $l} 100] puts [time {t2 $l} 100] - icomment:
Part of this issue has been fixed in ticket [b9ecf3ce9801c480]: If a single argument is given and that argument is a list containing more than one item, it can not be a level specification, so it is interpreted as the script to evaluate. Morever, no string representation is generated. The part of this issue that requires a TIP, as discussed in [1017884], remains outstanding.
- login: "pooryorick"
- mimetype: "text/x-fossil-wiki"
- severity changed to: "Minor"
Ticket change [c73f614379] (rid 186863) by dgp on 2020-09-19 17:04:08:
- closedate changed to: "2459112.21121291"
- closer changed to: "dgp"
- icomment:
Please also note that the list internal rep implementation has been improved in the many years since this ticket was opened. A canonical list is recognized now even after a string rep is generated. The cost of string rep generation now lmited to that actual cost of that processing step. It no longer disables the benefits of direct evaluation of lists without reparsing as scripts. That makes this issue far far less important, and that has been true for a very very long time now.
- login: "dgp"
- mimetype: "text/plain"