all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: tpeplt <tpeplt@gmail.com>
To: Drew Adams <drew.adams@oracle.com>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: [External] : Undefined behavior for the function ‘last’ or an error?
Date: Mon, 01 Apr 2024 14:35:30 -0400	[thread overview]
Message-ID: <87a5md9bil.fsf@gmail.com> (raw)
In-Reply-To: <SJ0PR10MB54888A11CF049379124BE449F33F2@SJ0PR10MB5488.namprd10.prod.outlook.com> (Drew Adams's message of "Mon, 1 Apr 2024 17:28:02 +0000")

Drew Adams <drew.adams@oracle.com> writes:

>
> IMO this should be fixed.  Someone(TM) will
> maybe say it's intentional (but then it
> should be doc'd).
>

Also, if it is intentional, then it should be documented why it is
inconsistent with how the related functions ‘butlast’ and ‘nbutlast’
behave so that users do not expect those two functions to accept
non-lists as an argument.

Also, checking a few other list functions, ‘nthcdr’, ‘take’, and
‘ntake’, there is a similar inconsistent result that might be
intentional or not.  The behavior of ‘nthcdr’ is unexpected, while the
behavior of ‘take’ and ‘ntake’ are unpredictable because these are
Emacs-Lisp-specific functions.

(nthcdr 0 'a) => a

(nthcdr 1 'a) => a
*** Eval error ***  Wrong type argument: listp, a

(take 0 'a) => nil

(take 1 'a) => nil
*** Eval error ***  Wrong type argument: listp, a

(ntake 0 'a) => nil

(ntake 1 'a) => nil
*** Eval error ***  Wrong type argument: listp, a

--



  reply	other threads:[~2024-04-01 18:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-01 16:53 Undefined behavior for the function ‘last’ or an error? tpeplt
2024-04-01 17:12 ` tpeplt
2024-04-01 17:28 ` [External] : " Drew Adams
2024-04-01 18:35   ` tpeplt [this message]
2024-04-01 19:25     ` Drew Adams
2024-04-01 20:11       ` tpeplt
2024-04-03  1:05         ` tpeplt

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

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

  git send-email \
    --in-reply-to=87a5md9bil.fsf@gmail.com \
    --to=tpeplt@gmail.com \
    --cc=drew.adams@oracle.com \
    --cc=help-gnu-emacs@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.