Skip to content
Tcl Source Code History Of Ticket 2673163
Login

History Of Ticket 2673163

Artifacts Associated With Ticket 2673163

  1. Ticket change [e83d8ddb57] (rid 104615) by ferrieux on 2009-03-08 21:40:01:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      The documentation for [upvar] says:
      
        upvar ?level? otherVar myVar ?otherVar myVar ...?
      
      which makes it pretty clear that the presence of a level is determined by the parity of the number of args: odd means level, even means no level.
      
      However, "upvar 1 x" raises a "wrong # args" error !
      
      This is due to the fact that the implementation ascribes higher priority to the value of the first argument ("integer affinity") than to positional criteria.
      
      This is Bad Thing (1) as it doesn't work as documented and (2) as it induces more verbose style, nullifying the intention of the "default level 1": programmers now routinely write "upvar 1 $x y" instead of the equivalent "upvar $x y" in fear of the above, insane behavior for an incoming integer-named variable.
      
      So I post this report proposing, as a fix, to just do as documented. That is, "upvar 1 x" should have the same effect as "upvar 1 1 x".
      
      Prio 8 as "low-hanging fruit" since (1) the patch is trivial and (2) the fix turns error cases into valid behavior in a way that really cannot harm a sane program.
      
      Patch to be shortly uploaded.
      
        
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "8"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "ferrieux"
    10. subsystem initialized to: "18. Commands M-Z"
    11. title initialized to: "Unwanted integer affinity of [upvar]"
    12. type initialized to: "Bug"
  2. Ticket change [4e478c5322] (rid 127197) by dkf on 2009-03-09 04:58:45:

    1. assignee changed to: "msofer"
    2. foundin changed to: "obsolete: 8.6b1.1"
    3. subsystem changed to: "07. Variables"
  3. Ticket change [cf9c431ff0] (rid 113017) by ferrieux on 2009-03-09 06:50:57:

    1. icomment:
      
      
      File Added - 316886: upvar.patch
      
      Attaching the promised patch.
      
      Please note that this patch insists on touching only Tcl_UpvarObjCmd, and not TclObjGetFrame, despite the latter having a very contorted domain (it maps many invalid strings to level 1 silently, and barfs only on out-of-range levels). The reason is that (1) TOGF is stubbed and hence its semantics should not be changed lightly, and (2) it is still reasonably efficient to check this from outside.
      
      Also note that the compiled-upvar paths don't need changing because (1) when the first arg is not known at compile time, upvar switches to runtime; and (2) when the first arg is an integer *and* the total number of args is even, the same switch occurs (initially thinking it would raise an error; but now it will Just Work).
      File Added: upvar.patch
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  4. Ticket change [1f1aab0285] (rid 91086) by msofer on 2009-03-09 08:14:10:

    1. assignee changed to: "ferrieux"
  5. Ticket change [5cb499f35f] (rid 115351) by andreas_kupries on 2009-03-09 23:24:40:

    1. icomment:
      As a side note, the TDK static syntax checker does check the command using odd/even to determine the presence of a level argument.
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  6. Ticket change [13640d94aa] (rid 124210) by ferrieux on 2009-03-10 06:15:47:

    1. icomment:
      
      
      File Added - 317096: upvar2.patch
      
      Updated patch modifies slightly TOGF, but in a compatible manner, by using NULL instead of the empty string as a magic value to get level 1. Suggestion by dkf. Also, improves the error message in case of toplevel access:
      
           upvar x y ;# at toplevel
           bad level "1"
      File Added: upvar2.patch
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  7. Ticket change [0395a10419] (rid 119853) by ferrieux on 2009-03-18 06:54:18:

    1. assignee changed to: "dgp"
    2. icomment:
      Reassigning to dgp for review.
      
      
    3. login: "ferrieux"
    4. mimetype: "text/plain"
    5. username: "ferrieux"
  8. Ticket change [a33b0f061b] (rid 110018) by ferrieux on 2009-03-19 03:30:02:

    1. icomment:
      
      
      File Added - 318435: upvar3.patch
      
      Updating patch to HEAD
      File Added: upvar3.patch
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  9. Ticket change [b78675624b] (rid 125613) by dgp on 2009-03-19 03:48:48:

    1. assignee changed to: "dkf"
    2. icomment:
      
      On a superficial level, the code doesn't follow
      the usual Tcl Engineering Manual conventions, and
      would be better reformatted before commit.
      
      On substance, the decision to accept comes down
      to a judgment on whether to object to replacing
      one error with another, as demonstrated in the
      changes to test upvar-8.3.  I'm the wrong one
      to make that judgment.  At the moment I just don't
      care.  I suspect when I'm in a better mood, I
      still won't care.  Folks should just code the
      level explicitly.
      
      As I understand it, the identifiable case that
      is most clearly an actual bug to fix is
      
          upvar 1 x
      
      so it would be good to have a test case
      for that, and check that the docs are clear
      that the interpretation choice on it is
      correct.
      
      In the niggly details, I don't see the value
      of setting name to "1" in TclObjGetFrame().
      The value isn't used.
      
      I'm left wondering about the impact on
      other commands that have level values which
      are optional, such as [uplevel].  Not curious
      enough to go looking though.  If there's a
      general problem, it's best to commit all
      solutions at once.
      
      
    3. login: "dgp"
    4. mimetype: "text/plain"
    5. username: "dgp"
  10. Ticket change [3ef16c4b71] (rid 121362) by dgp on 2009-03-19 03:51:42:

    1. icomment:
      
      well, I reviewed upvar2.patch.
      
      If upvar3.patch is significantly
      different, ignore everything I said.
      
      I'm done with this one.
      
      
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. username: "dgp"
  11. Ticket change [f1ff0004bc] (rid 109453) by ferrieux on 2009-03-19 04:27:19:

    1. icomment:
      "Folks should just code the level explicitly" is just contrary to 10+ years of unchanged documentation and usage, and also to the "Huffmann principle", meaning that the dominant use should be written concisely.
      
      The name value "1" in TOGF *is* used on the error path, to generate the message 'bad level "1"' when the requested implicit level 1 is nonexistent (like 'upvar x y' at toplevel).
      
      About the generalization to [uplevel], it is impossible since upvar has no constraints on the parity or #args, so positional/parity cues are not usable.
      
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  12. Ticket change [d1e558a4fe] (rid 113430) by ferrieux on 2009-03-19 04:45:37:

    1. icomment:
      
      
      File Added - 318446: upvar4.patch
      
      typo in previous message, should read "... since _uplevel_ has no constraints..."
      
      Attaching patch including extra test for [upvar 1 x], and style (hopefully) conformingto the Eng.Man. 
      File Added: upvar4.patch
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  13. Add attachment "upvar4.patch" [baced1bf55] (rid 129384) by ferrieux on 2009-03-19 04:45:37.

  14. Ticket change [5426402a06] (rid 93888) by dkf on 2009-03-23 23:27:32:

    1. icomment:
      Please delete the patches that you don't want me to review :)
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  15. Ticket change [c84c9e894b] (rid 122077) by ferrieux on 2009-03-24 00:29:01:

    1. icomment:
      Done.
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  16. Ticket change [fda60413bf] (rid 108439) by ferrieux on 2009-03-24 00:29:02:

    1. icomment:
      
      
      File Deleted - 318435: 
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  17. Ticket change [0eec46f616] (rid 94707) by dkf on 2009-03-24 16:31:05:

    1. icomment:
      Looked good to me. Applied (after tweaking variable names).
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  18. Ticket change [0126338fe0] (rid 119427) by dkf on 2009-03-24 16:31:06:

    1. closedate changed to: "2009-03-24T09:31:06"
    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"