emacs-devel
[Top][All Lists]
Advanced

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

RE: Internationalize Emacs's messages (swahili)


From: Drew Adams
Subject: RE: Internationalize Emacs's messages (swahili)
Date: Fri, 1 Jan 2021 14:55:49 -0800 (PST)

> > If we're defining predicates to check whether the length of a list is
> > <, =, or > some value, those predicates should do something useful, or
> > at least something one might expect, for non-proper lists as well, no?
> 
> What exactly means "something one might expect"?
> 
> I expect the predicates to work on proper list and
> it should count the number of cons cells in the list.
> 
> I do not expect the predicates to count the last cdr differently
> depending on its value.

The question iss not what the behavior should be
for proper lists.  The question is what it should
be for dotted lists (and circular lists).

What is your reasonable expectation for dotted lists?

I'd suggest these are two reasonable expectations
for a dotted-list length comparison against a number:

1. Always raise an error.
2. Never raise an error.

For #2, one reasonable expectation is, I think,
that the value returned always be true or false,
and exactly mirror the case for a proper list
whose last element is the last cdr of the dotted
list.

That has a good deal of consistency.  Non-nil
cdrs are simply counted (irrespective of their
non-nil values).  Nothing more happens.

(And the same can be said for a proper list:
the non-nil cdrs are counted - nothing more.)

"List" includes both proper and dotted lists.
Because a list can have a non-nil last cdr, it's
non-nil cdrs that I'd expect should be counted,
not cons cells.

But that's me.  To me, that behavior for dotted
lists would at least be of some _use_.  Always
raising an error for a dotted list is less useful.

But even if for some reason (what reason?) you
think #2 is _more_ useful, we don't even have #2.

The question really is, What behavior do you want
for a dotted list?

So far, the behavior is to sometimes (1) raise
an error and sometimes (2) return a true or false
value.  And there's little rhyme or reason for
when it does one or the other.

These use my Lisp definitions, which I guess do
what the current C code does for dotted lists:

(length> '(1 . 2) -1) ; true
(length> '(1 . 2) 0)  ; true
(length> '(1 . 2) 1)  ; true
(length> '(1 . 2) 2)  ; ---ERROR---
(length> '(1 . 2) 42) ; ---ERROR---

(length< '(1 . 2) -1) ; false
(length< '(1 . 2) 0)  ; false
(length< '(1 . 2) 1)  ; false
(length< '(1 . 2) 2)  ; false
(length< '(1 . 2) 24) ; ---ERROR---

(length= '(1 . 2) -1) ; false
(length= '(1 . 2) 0)  ; false
(length= '(1 . 2) 1)  ; false
(length= '(1 . 2) 2)  ; ---ERROR---
(length= '(1 . 2) 42) ; ---ERROR---

Is that really what you expect/want?  Not I.

I prefer that those ERROR cases return false
for >, and true for = and <.  Which is what
I implemented.



reply via email to

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