emacs-devel
[Top][All Lists]

## RE: Predicate for true lists

 From: Drew Adams Subject: RE: Predicate for true lists Date: Fri, 6 Jul 2018 10:00:34 -0700 (PDT)

```1. Why is "proper" better than "true"?  I don't argue
against "proper", but what is really gained by this
change in Emacs terminology?

Dunno how helpful this is (perhaps not very), but it
purportedly shows how often "proper" and "true" appear
in print as modifiers of "list" recently:

They both are rare, and there doesn't seem to be much
difference in their frequencies.  If anything, "true list"
is more used.  (But this is not based only on mathematical
texts - it just counts books in print.)

2. You say this in the doc string of `proper-list-length':

A proper list is neither circular nor dotted (i.e., its
last cdr is nil).

And your entry in the manual for that function:

In addition to satisfying @code{listp}, a proper list is
neither circular nor dotted.

Fair enough, but it depends on what is meant by a "circular"
list.  Does it mean only a list whose last cdr shares list
structure with some other of its cdr's?  If so then what you
say holds.  And yes, I guess that's what most of us think of.

But what of a list that has a finite number of elements,
so it last cdr is nil, but one or more of whose elements
is itself a circular list in the above sense?  Is it in
some sense "circular" because of its circular-list element?

IOW, a list can have finite length but still share list
stucture with itself.  Well, no, not really, but an
element of it can be a list that shares list structure
with itself.  And so the finite-length list represents
an infinite tree.

For example, here's a one-element list whose only
element is the circular list (a a a a a a ...):

(setq foo '((a)))
(setcdr (car foo) foo)

foo          ; ((a #1))
(length foo) ; 1

(nth 0 foo)  ; (a #0)
(nth 1 foo)  ; nil
(nth 0 (nth 0 foo)) ; a
(nth 1 (nth 0 foo)) ; (a #0)
(nth 2 (nth 0 foo)) ; nil
(nth 0 (nth 0 (nth 0 foo)) ; a
(nth 0 (nth 1 (nth 0 foo)) ; (a #0)
(nth 0 (nth 2 (nth 0 foo)) ; nil
...

It should be enough to say that a "true", or "proper"
list is one that has nil as its last cdr, without