bug-gnu-emacs
[Top][All Lists]
Advanced

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

Re: replacing a certain element in a list with another


From: Kevin Rodgers
Subject: Re: replacing a certain element in a list with another
Date: Thu, 23 Oct 2003 09:30:42 -0600
User-agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:0.9.4.1) Gecko/20020406 Netscape6/6.2.2

Stefan Monnier wrote:
>Roland Winkler wrote:

It might be helpful to add a comment to the docstring or info page
for nreverse saying that its argument is modified such that
afterwards it is a 1-element list containing the last element of the
reversed list.

I don't think this particular aspect of the behavior should be documented.
Maybe we should add a note saying "the argument should not be used
afterwards", but even that would not be very convincing.
I think the only reasonable thing to put is a "don't use this unless you
know what you're doing".

Why not document all the destructive list operations like delq, whose
doc string says:

If the first member of LIST is ELT, there is no way to remove it by side
effect; therefore, write `(setq foo (delq element foo))' to be sure of
changing the value of `foo'.

For nreverse, it would be:

Because the first cons cell of LIST is the last cons cell of the
returned list, write `(setq foo (nreverse foo))' to set `foo' to its
reversed value.

--
Kevin Rodgers





reply via email to

[Prev in Thread] Current Thread [Next in Thread]