unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: The doc-strings for car and cdr are insulting.
Date: Thu, 28 Oct 2004 12:44:45 +0200	[thread overview]
Message-ID: <x5vfcv3yw2.fsf@lola.goethe.zz> (raw)
In-Reply-To: <Pine.LNX.3.96.1041027183957.614A-100000@acm.acm> (Alan Mackenzie's message of "Wed, 27 Oct 2004 18:56:22 +0000 (GMT)")

Alan Mackenzie <acm@muc.de> writes:

> I'm assuming that you (RMS) won't mind me posting this to emacs-devel,
> since it's not essentially a personal email.]
>
>>    I suggest these doc-strings be amended to:
>>
>>    "Return the first element of LIST.  If arg is nil, return nil. ....."
>>
>>    and
>>
>>    "The result of removing the first element from LIST, or nil if arg is nil.
>>     Error if arg .....".
>
>>I don't reject the idea of making these doc strings clearer; however,
>>this is not the right way present the concepts.
>
> I was thinking that, although my proposed doc-strings are not the
> whole truth, they might be the clearest explanation for a raw
> beginner at lisp.

No.  No no no.  A cons cell is _the_ fundamental data structure of
Lisp.  We must not start waffling around that: this would only confuse
people that have made themselves familiar with the terminology.

And "the result of removing the first element from list" is completely
wrong anyway since no element is removed: the list stays intact.

The main sentence _has_ to be

Return the car/cdr of CONS, or nil if CONS is nil.

You can then add below:

It is an error if CONS is neither a cons cell nor nil.  If CONS
represents an ordinary list, {`car' will return its first
element,`cdr' will return the list without its first element}.

Something like that.

> How about something like the following, changing "LIST" to "CONS", and
> using "lhs" and "rhs":
>
> "car is a built-in function.
>  (car CONS)
>
>  Return the \"left hand side\" of CONS.  If CONS is nil, return nil.
>  If CONS is a list, the car is its first element.
>  Error if arg is not nil and not a cons cell.  See also `car-safe'."

It is just confusing to introduce artificial one-shot terms that are
basically meaningless, like "left hand side".  It implies a left/right
symmetry that is not present when used as a list: the "left" side
points to a list member, the "right" side points to a list of its own.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

  parent reply	other threads:[~2004-10-28 10:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1CMlLW-0000cN-HD@fencepost.gnu.org>
2004-10-27 18:56 ` The doc-strings for car and cdr are insulting Alan Mackenzie
2004-10-27 23:35   ` Luc Teirlinck
2004-10-27 23:40   ` Luc Teirlinck
2004-10-28 10:44   ` David Kastrup [this message]
2004-10-29  4:32   ` Richard Stallman
2004-10-29 10:12     ` Lennart Borgman
2004-10-29 15:32     ` Kevin Rodgers
2004-10-30  0:21       ` Chris Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=x5vfcv3yw2.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).