Skip to content
Tcl Source Code View Ticket
Login

View Ticket

[append x] gives an error when x doesn't exist

Open1227172fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 20 days ago
Descriptionplain2005-06-24 18:12:16
This:
 
  catch {unset x}
  puts [append x]

gives an error:

  can't read "x": no such variable
      while executing
  "append x"
      invoked from within
  "puts [append x]"

although the docs seem to say that it should just return the value of x. 
What's worse is that lappend *does* just return the value of x, so the two 
are inconsistent.
mdiepplain2005-06-25 01:16:09
Logged In: YES 
user_id=1302408

I forgot to mention that there are tests for both of these cases: append-3.3 and 
append-4.18. append-3.3 should be changed to reflect the desired behavior.
dkfplain2005-06-26 06:06:38
Logged In: YES 
user_id=79902

Looking at the tests, it is clear that they're *old* and
that Tcl's been like this for, well, donkey's years. And of
the trio of [set], [append] and [lappend], it is [lappend]
that is the odd one out.

Any change is going to require careful consultation...
dkfplain2005-12-16 18:05:15
data_type - 360894
dkf Ticket [1227172fff]: 1 change [History diff]2005-12-16 18:06:07
dkfplain2009-07-13 01:24:02
Passing to person who worked on "do nothing gracefully" TIP (#323).
serhiy.storchaka Ticket [1227172fff]: 2 changes [History diff]2026-11-13 11:18:46
Log in (anonymous is fine) to add a comment.