help-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: Roland Winkler
Subject: Re: replacing a certain element in a list with another
Date: 24 Oct 2003 00:03:24 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Barry Margolin <barry.margolin@level3.com> writes:

> In article <m3u160cea8.fsf@tfkp07.physik.uni-erlangen.de>,
> Roland Winkler  <Roland.Winkler@physik.uni-erlangen.de> 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.
> 
> Why?  Then if someone came up with a way to do the reversing efficiently in
> a different way, they wouldn't be able to change it, because the
> documentation would lock them into the current behavior.
> 
> The documentation should only specify the parts of the behavior that users
> can depend on, not incidental results of a particular implementation.

The info page for nreverse gives an example for the results obtained
by the present implementation of nreverse where the argument is
converted into a 1-element list containing the last element of the
reversed list. I find this example rather confusing because it is
given wihtout further explanation which rules nreverse is obeying
when it modifies its argument destructively. However, if I
understand you correctly it does not even make sense to ask which
rules nreverse is using here because they depend on the
implementation of nreverse. It is nothing one could rely upon.

If indeed we are talking here about something that is
implementation-dependent, it would be better to replace this example
with a sentence saying that nreverse "destroys" its argument in an
implementation-dependent way such that only the return value is a
well-defined object. Then I would know that it doesn't make sense to
ask the question whether the argument of nreverse may be used for
anything else after it was passed to nreverse.

Or am I missing something here?

Roland


reply via email to

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