[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

APPEND-DOTTED



Issue:        APPEND-DOTTED
References:   APPEND (p268)
Category:     CHANGE/CLARIFICATION
Edit history: 27-Jul-87, Version 1 by Pitman
Status:	      For Internal Discussion

Problem Description:

  The description of APPEND on p268 is not adequately clear on the issue of
  what happens if an argument to APPEND is a dotted list.

Proposal (APPEND-DOTTED:REPLACE):

  Define that the cdr of the last cons in any but the last list given to
  append is discarded (whether NIL or not) when constructing the new list.

  Remove any text which suggests that (APPEND x '()) and (COPY-LIST x) are
  the same, since these two might legitimately differ in situations involving
  dotted lists. As such, deciding which to use is not just a stylistic issue.

Test Case:

  (APPEND '(A B C . D) '()) => (A B C)		;Proposed

  [Note that (COPY-LIST '(A B C . D)) would still return (A B C . D).]

Rationale: 

  This function is used a lot and its behavior should be well-defined across
  implementations. This proposal upholds the apparent status quo in a number
  of implementations.

Current Practice:

  Symbolics Lisp, Vaxlisp, and Lucid Lisp appear to implement the proposed
  interpretation (at least in the interpreter).

Adoption Cost:

  Technically, the change should be relatively small for those
  implementations which don't already implement it. However:

  If there are any implementations which have microcoded APPEND incompatibly,
  the small change may nevertheless be somewhat painful.

  Some implementations may have optimized their APPEND to expect only NIL
  when SAFETY is 0. In this case, depending on implementation details, 
  requiring an ATOM check rather than a NULL check may slow things down.

Benefits:

  Since non-lists are allowed as a last argument and since APPEND can
  therefore produce dotted lists, some readers may have (incorrectly)
  assumed that APPEND can reliably deal in general with dotted lists, 
  something that doesn't appear to be guaranteed by a strict reading. The
  proposed extension would happen to legitimize such assumptions.

Conversion Cost:

  This change is "upward compatible".

Aesthetics:

  Whether or not users will think this improves the aesthetics of the
  language will depend largely on how they view the relation between
  lists and dotted lists. Those who view dotted lists as a special kind
  of list may feel differently than those who view lists as a special
  kind of dotted list.

Discussion:

  KMP supports the proposed extension.