unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Philipp Stephani <p.stephani2@gmail.com>
Cc: Rajeev Narang <rajeev.jnk@sivalik.com>,
	47391@debbugs.gnu.org, Emacs developers <emacs-devel@gnu.org>
Subject: Re: bug#47391: 27.2; static list return from function and nconc
Date: Thu, 25 Mar 2021 11:43:20 -0400	[thread overview]
Message-ID: <jwvtuozb5ph.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAArVCkRmjEXQdhCod0mhOa0MRqM=quqcbESOCJHpbz2jnoyoLg@mail.gmail.com> (Philipp Stephani's message of "Thu, 25 Mar 2021 16:28:26 +0100")

>> (defun fn () '(1 2))
>>
>> (nconc (fn) '(3))
>> -> (1 2 3)
>
> This is undefined behavior/unsupported. The value that (fn) evaluates
> to is immutable, but nconc mutates it.
>
>>
>> (nconc (fn) '(3))
>> -> (1 2 3 3) ? should be (1 2 3)
>>
>> If this is not a bug, then hfy-invisible, hfy-face-to-style-i may need to be fixed.
>
> If they use this pattern, then they should indeed be fixed.

Note that in the code above, we usually consider that the bug is not in
`fn` but in the use of `nconc` on a list which the code doesn't know can
safely be mutated (it should hence use `append` instead).


        Stefan




  reply	other threads:[~2021-03-25 15:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-25 14:54 bug#47391: 27.2; static list return from function and nconc Rajeev Narang via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-25 15:28 ` Philipp Stephani
2021-03-25 15:43   ` Stefan Monnier [this message]
2021-03-25 15:55 ` Gregory Heytings
2021-03-25 15:58   ` Stefan Monnier
2021-03-25 16:03     ` Gregory Heytings

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=jwvtuozb5ph.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=47391@debbugs.gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=p.stephani2@gmail.com \
    --cc=rajeev.jnk@sivalik.com \
    /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).