From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: tpeplt Newsgroups: gmane.emacs.help Subject: Undefined behavior for the function =?utf-8?B?4oCYbGFzdOKAmQ==?= or an error? Date: Mon, 01 Apr 2024 12:53:21 -0400 Message-ID: <87il119g8u.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23067"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 01 18:53:56 2024 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rrKuy-0005m2-Lj for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 01 Apr 2024 18:53:56 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rrKuV-00052k-Ut; Mon, 01 Apr 2024 12:53:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rrKuU-00052V-9b for help-gnu-emacs@gnu.org; Mon, 01 Apr 2024 12:53:26 -0400 Original-Received: from mail-qv1-xf2b.google.com ([2607:f8b0:4864:20::f2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rrKuS-0001nV-Ir for help-gnu-emacs@gnu.org; Mon, 01 Apr 2024 12:53:26 -0400 Original-Received: by mail-qv1-xf2b.google.com with SMTP id 6a1803df08f44-690fed6816fso24192656d6.1 for ; Mon, 01 Apr 2024 09:53:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711990403; x=1712595203; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=YibOAd2xgKtJ7/8Rex8V15WFbgEmmiIHQLC6MTfZVYA=; b=E8/Uu2G1oZ9plt+01gDGOOsQYN2q1QLNGZ5K0E1VxhM8ajH/DW3+sWPVJY5/bR9lf7 l9qY6mtNLYeeKx8UsOAgeShzR1ETnVmzxRulZgp/h3b2AxcPOL17uH+HuxKjGVI8ZFi8 n5/oZZuq85fir1Kq5/i29ldxtlwTUghEr6nF9HpnAli/E86YHoC+cQys2uAR4bfWPexa 3zb0K1o4D0BxI9B8141ch7SoDiCN7rR1kPE3bIS+H/ByrZgH3KZcmNJWxXRWQqw9oxDk tt3hP/Ik1SwxjOGSvDhk2Jhn8NDGNZsAz3dyB/nycYhs91S2Xqo5sCjCjlSaVofqj0rA 96nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711990403; x=1712595203; h=content-transfer-encoding:mime-version:user-agent:message-id:date :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YibOAd2xgKtJ7/8Rex8V15WFbgEmmiIHQLC6MTfZVYA=; b=hbJC97sUqMuHxmpJC3mSbSwJMVb8ILxgOuZamuur7h/6SJ8DJhgthxlDnIhiVfUR5M 1HLA5/dgwgBlWsh1STKh3x5nUgCzyFpbEOincmBOGWEqlO0i/dJN3YQs4qHzgOv5H7LU JI4DXLLrzEHeztdzH/FBHepb8KzFLErGLxHdL/Sz99OiQbDjoYFIrcsivWxPFuMqjNHC 3a4YBAaQ4onKKzMwCEl4RpPaC6nW8jHUa5c5E1zgwYnpi5lg4ERWuvw1/yZ9hUJluszy lcNVBvIPTqBjFrZ/hRvsfStOlPsgAKITD20Fmj4jTI+JTOEHz+djJeAzmJS4y0KCGBLG AcSA== X-Gm-Message-State: AOJu0YwQjyWdSmrdtdFLUpNu5t8pLX2yr8vPxQ9+DaE7yXWYEqkNnhAc TRJ7sDDTOew9z44HxIEBTpElvSUETvos6rb2VOdPgdMAW1AvY1RbGIODlr+Ez+Y= X-Google-Smtp-Source: AGHT+IGkD/fW5Yo/ihw8vfUfgylqGWA/nGAmiao8eZaaS7af1CrJaCQ8eK8kb5ilMKKhH8D7J+t0sQ== X-Received: by 2002:a05:6214:124f:b0:690:b782:bc9e with SMTP id r15-20020a056214124f00b00690b782bc9emr12903761qvv.53.1711990403462; Mon, 01 Apr 2024 09:53:23 -0700 (PDT) Original-Received: from t530.local ([2600:8806:a821:2b00::5acf]) by smtp.gmail.com with ESMTPSA id jf11-20020a0562142a4b00b006987272f5cbsm4358258qvb.71.2024.04.01.09.53.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 09:53:22 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::f2b; envelope-from=tpeplt@gmail.com; helo=mail-qv1-xf2b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:146218 Archived-At: The built-in Emacs Lisp function =E2=80=98last=E2=80=99 accepts a list as i= ts argument: (last '(a b c)) =3D> (c) It also (surprisingly) accepts a non-list as its argument: (last 'a) =3D> a (last 3.14) =3D> 3.14 (last "string of chars") =3D> "string of chars" Contrast this with =E2=80=98butlast=E2=80=99 and =E2=80=98nbutlast=E2=80=99: (butlast 'a) *** Eval error *** Wrong type argument: sequencep, a (butlast 3.14) *** Eval error *** Wrong type argument: sequencep, 3.14 (butlast "string of chars") *** Eval error *** Wrong type argument: listp, "string of chars" Is this behavior by =E2=80=98last=E2=80=99 an error, is it correct and undo= cumented, or is it correct and documented in some obscure (to me) location? Below are the docstring for =E2=80=98last=E2=80=99 and the entry in the eli= sp reference manual. Neither mentions this behavior by =E2=80=98last=E2=80=99. Docstring for =E2=80=98last=E2=80=99: (last LIST &optional N) Return the last link of LIST. Its car is the last element. If LIST is nil, return nil. If N is non-nil, return the Nth-to-last link of LIST. If N is bigger than the length of LIST, return LIST. >From (info "(elisp) List Elements"): -- Function: last list &optional n This function returns the last link of LIST. The =E2=80=98car=E2=80= =99 of this link is the list=E2=80=99s last element. If LIST is null, =E2=80=98ni= l=E2=80=99 is returned. If N is non-=E2=80=98nil=E2=80=99, the Nth-to-last link is = returned instead, or the whole of LIST if N is bigger than LIST=E2=80=99s lengt= h. --