[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: &REST lists
- To: common-lisp@SAIL.STANFORD.EDU
- Subject: Re: &REST lists
- From: willc%tekchips.CRL@tektronix.tek.com
- Date: Tue, 29 Mar 1988 17:17:00 -0000
- Cc: firstname.lastname@example.org
Page 272 of CLtL, talking about RPLACA and RPLACD, says:
...caution should be exercised when using these functions,
as strange side effects can occur if portions of list
structure become shared.
If APPLY is permitted to side effect its last argument, as advocated
by most participants in the recent discussion, then language similar
to that above should be added to the discussion of APPLY on page 107.
The cautionary language is much more important for APPLY than for
RPLACA and RPLACD because side effects are the whole point of the
latter, but it would be easy for a naive programmer to assume that
APPLY has no gratuitous side effects.
In a recent posting, Eliot Moss revealed that he does not have the
correct model of argument transmission in Common Lisp. He erroneously
believes that CL procedures take sequences of arguments; if this were
the case, one could of course prove that APPLY cannot side effect the
top level of its last argument. Because APPLY can have such side
effects, however, any correct model of CL argument transmission must
have it that at least some CL procedures (those that have a &REST arg)
can accept a linked list (not a sequence) of arguments. If procedures
are to be treated uniformly by the model, then all CL procedures must
accept a linked list of arguments rather than a sequence.
Although this might seem to imply that the CL runtime must cons up
these argument lists for all calls that don't involve APPLY, it happens
that the CL compiler can in practice avoid the consing by observing that
the first operation performed by all procedures except those with &REST
arguments is to take the argument list apart into a sequence; furthermore
there is enough slack in the semantics of procedures with &REST arguments
-- the &REST argument need not share structure with the argument list,
although it may -- that it's ok to avoid the consing even when the compiler
is unable to prove that the procedure being called does not take a &REST
I think Moss would agree with me that this is a ridiculous model of
argument transmission, but it shows that the semantics advocated by
his opponents can be made consistent.
Semantic Microsystems, Inc.