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

History Of Ticket 1049119fffffffff

Artifacts Associated With Ticket 1049119fffffffff

  1. Ticket change [22f93f3085] (rid 130844) by nobody on 2004-10-18 10:20:28:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Behavior of append and lappend with one argument is
      undocumented and inconsistent.
      
      Using both lappend and append with just one argument is
      allowed
      according to 8.5 (and likely all previous) manual
      pages, arguments to
      both are specified as:
      
        varName ?value value value ...?
      
      It is however undocumented what happens when just
      varName is
      present.
      
      Manual suggests consistent behavior of lappend and append:
      
        "Lappend is similar to append except that the values
      are appended 
         as list elements..."
      
      However in 8.3 (and likely in all versions), lappend
      can create new
      variable this way while append cannot:
      
        ~>tclsh
        % append x
        can't read "x": no such variable
        % lappend y
        % 
      
      This should probably be considered as bug in append as
      the manual says:
      
        "If varName doesn't exist, it is given a value equal
      to the
         concatenation of all the value arguments."
      
      so one might expect that concatenation of no value
      arguments is an
      empty string which should become the value of newly
      created variable.
      
      Furthermore, it is unclear whether lappend with one
      argument will
      normalize any pre-existing value into the canonical
      list form or
      not. In 8.3 it will not, which might be regarded as an
      inconsistency
      with behavior when used with more arguments:
      
        % set x { a}
        % puts /[lappend x]/
        / a/
        % puts /[lappend x b]/
        /a b/
      
      This slight difference might become important if
      applications use
      current behavior of "lappend x" as a nice way to create
      x or leave it
      unchanges if it exists. Future versions of tcl might
      change this
      undocumented 'feature' and break these applications.
      
      Both lappend and append are quite basic commands and
      should not 
      have uncertain behavior.
      
      Recommended action:
      
      a. fix append so that "append x" can create x
      b. document behavior of "append x" and "lappend x"
      
      Alternatively, consider these (IMHO inferior) solutions
      instead:
      
      c. document that "append x" cannot create x while
      "append x a" can
      d. change lappend so that "lappend x" list-normalizes x
      
      (By a quick manual scan, I did not find any other list
      operation which
      could become no-op like "lappend x" with pre-existing
      x. If there is
      any, it should be made consistent whether they all
      list-normalize x or
      not.)
      
      e. disallow "append x" and "lappend x"
      
      This last solution would be the worst (IMHO) as is
      would deprive
      users of very convenient:
      
        lappend x
        set x [concat x y]
      
      which creates x when needed and works regardless of (d.)
      
      Vaclav Hanzl, email:  hanzl (x@x) noel.feld.cvut.cz
      
      
    4. foundin initialized to: "obsolete: 8.5a1"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "16. Commands A-H"
    10. title initialized to:
      append and lappend with one arg undocumented & inconsistent
      
    11. type initialized to: "RFE"
  2. Ticket change [0c767ec45f] (rid 114180) by dkf on 2004-10-19 22:45:15:

    1. assignee changed to: "msofer"
    2. icomment:
      Logged In: YES 
      user_id=79902
      
      Hmm, is the difference between [append] and [lappend]
      deliberate or accidental?  Your opinion, Miguel?
      
      
    3. login: "dkf"
    4. mimetype: "text/plain"
    5. username: "dkf"
  3. Ticket change [75b62c0eac] (rid 105432) by nobody on 2004-10-20 15:27:21:

    1. icomment:
      Logged In: NO 
      
      I would bet that behavior of [append x] is accidental.
      
      While I do not see reasons for a deliberate
      difference, I see some difference in motivation
      to mess with [append x] and [lappend x].
      
      If [append x] fails to do what I expect it to do,
      I can use [append x ""] instead. There would
      be no such replacement for defunct [lappend x].
      It is therefore easier for [append x] to escape
      attention.
      
      If somebody discovered that current strange
      behavior of [append x] is exactly equivalent
      to [set x], did not submit a bug report and went
      on to create programs dependent on this, than
      he well deserves some punishment like 
      incompatible change of [append x] :-)
      
      On the other hand, [lappend x] is currently
      equivalent to [if {![info exists x]} {set x ""}]
      (well, return value is different) and might
      be used as a nice shorthand.
      Some smarties might even routinely do:
      
      eval lappend x $y
      
      instead of:
      
      if {![info exists x]} {
        set x {}
      }
      set x [concat $x $y]
      
      After some googling for "eval lappend" and
      "eval append" I see that both are used
      and fixing [eval x] might actually fix more
      programs than it breaks.
      
      Vaclav Hanzl, email: hanzl (x@x) noel.feld.cvut.cz
      
      
      
    2. login: "nobody"
    3. mimetype: "text/plain"
    4. username: "nobody"
  4. Ticket change [df276d3a61] (rid 114970) by msofer on 2005-04-16 23:12:39:

    1. assignee changed to: "dkf"
    2. icomment:
      Logged In: YES 
      user_id=148712
      
      Sorry, this somehow flew under my radar.
      
      Looks accidental to me, although it is explicitly tested for
      in the testsuite: append-3.3, append-4.6  
      
      I tend to agree with Vaclav as to what "should" happend.
      OTOH, this is not the only inconsistency between [append]
      and [lappend]: the second will call read traces on the
      variable, while the first will not (see FR 433252).
      
      I hesitate to change something that is as fundamental and
      has existed forever without a *lot* of very public
      discussion. And probably not in a minor release anyway. Opinion?
      
      
    3. login: "msofer"
    4. mimetype: "text/plain"
    5. username: "msofer"
  5. Ticket change [9e646ff403] (rid 96463) by nobody on 2005-05-28 05:27:27:

    1. icomment:
      Logged In: NO 
      
      I absolutely agree that more discussion is needed. Trying to
      re-align a cornerstone is worth thinking about as it can be
      both good and bad idea. Maybe it should become two oposed
      TIPs, the first being "Fix append x" and the second being
      "Document current strange append x".
      For the minor release, there is an ugly but honest option to
      add some warning to the append man page ("Do not make any
      assumptions about append x, it is strange and may be
      reconsidered").
      Would be nice to be able to grep World's tcl codebase for
      "eval append" and count bugs caused by the fact that author
      was unaware of the current behavior of append.
      Googling reveals some related older discussion:
      http://groups.yahoo.com/group/wintcl/message/740
      
      Vaclav Hanzl
      
      
    2. login: "nobody"
    3. mimetype: "text/plain"
    4. username: "nobody"
  6. Ticket change [a231e60480] (rid 109846) by dkf on 2005-12-16 18:14:06:

    1. foundin changed to: "None"
    2. icomment:
      
      
      data_type - 360894
      
      
      
    3. login: "dkf"
    4. mimetype: "text/plain"
    5. subsystem changed to: "16. Commands A-H"
    6. username: "dkf"
  7. Ticket change [80e74fe505] (rid 116948) by dkf on 2009-07-13 01:27:16:

    1. assignee changed to: "dgp"
    2. icomment:
      Passing to author of TIP#323 for consideration (see also issue:1227172).
      
      
    3. login: "dkf"
    4. mimetype: "text/plain"
    5. username: "dkf"
  8. Ticket change [ef32703731] (rid 261561) by serhiy.storchaka on 2026-11-13 11:18:46:

    1. login: "serhiy.storchaka"
    2. type changed to: "Bug"