From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: replacing a certain element in a list with another Date: Thu, 23 Oct 2003 22:20:34 GMT Organization: Level(3) Communications, Woburn, MA Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <8jSlb.186$lK3.106@news.level3.com> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1066948367 28395 80.91.224.253 (23 Oct 2003 22:32:47 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 23 Oct 2003 22:32:47 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 24 00:32:42 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ACo0X-0007sS-01 for ; Fri, 24 Oct 2003 00:32:42 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1ACnyz-0001kx-QU for geh-help-gnu-emacs@m.gmane.org; Thu, 23 Oct 2003 18:31:05 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!elnk-nf2-pas!elnk-pas-nf1!newsfeed.earthlink.net!newsfeed2.easynews.com!newsfeed1.easynews.com!easynews.com!easynews!crtntx1-snh1.gtei.net!news.gtei.net!news.level3.com.POSTED!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help Mail-Copies-To: never X-Newsreader: trn 4.0-test72 (19 April 1999) Originator: barmar@genuity.net (Barry Margolin) Original-Lines: 52 Original-NNTP-Posting-Host: 171.78.176.30 Original-X-Trace: news.level3.com 1066947634 171.78.176.30 (Thu, 23 Oct 2003 22:20:34 GMT) Original-NNTP-Posting-Date: Thu, 23 Oct 2003 22:20:34 GMT Original-Xref: shelby.stanford.edu gnu.emacs.help:117572 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:13505 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:13505 In article , Roland Winkler wrote: >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? The idea of Emacs documentation describing something as "implementation-dependent" is kind of weird. Emacs Lisp is not a general purpose language with multiple implementations, it's a part of Emacs. So the documentation is describing just this one implementation. I don't have the Emacs Lisp info pages online, but the built-in documentation says: Reverse LIST by modifying cdr pointers. Returns the beginning of the reversed list. This is terse, but it pretty much describes what I explained in detail a few messages back. The fact that any references to the old list will now refer specifically to the last cons in the new list is a natural result of this; you just need to understand how lists are built out of cons cells. But this specific result is not considered important -- no one ever writes a program that depends specifically on what the old references point to. The verbose documentation of all the destructive list operations should mention that you must use the value to get the expected results all the time, rather than depending on everything to work due to the lists being modified in place. -- Barry Margolin, barry.margolin@level3.com Level(3), Woburn, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups. Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.