Tcl Source Code

View Ticket
Login
Ticket UUID: 1227172
Title: [append x] gives an error when x doesn't exist
Type: Bug Created on: 2005-06-24 18:12:16
Submitter: mdiep Assigned to: dgp
Subsystem: 16. Commands A-H Severity:
Priority: 3 Low Last modified: 2026-11-13 11:18:46
Status: Open Closed by:
Resolution: None Closed on:
Version: None
Description:
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.
User Comments:
mdiep added on 2005-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.

dkf added on 2005-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...

dkf added on 2005-12-16 18:05:15:

data_type - 360894

dkf added on 2009-07-13 01:24:02:
Passing to person who worked on "do nothing gracefully" TIP (#323).