all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Heerdegen via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Okamsn <okamsn@protonmail.com>
Cc: 68863@debbugs.gnu.org, eliz@gnu.org, monnier@iro.umontreal.ca,
	nicolas@petton.fr
Subject: bug#68863: Add support for using setf with seq-subseq
Date: Tue, 14 May 2024 17:52:49 +0200	[thread overview]
Message-ID: <87zfssl7am.fsf@web.de> (raw)
In-Reply-To: <538ac066-c421-4c1a-8714-0864917211e6@protonmail.com> (okamsn@protonmail.com's message of "Tue, 14 May 2024 12:47:14 +0000")

Okamsn <okamsn@protonmail.com> writes:

> Here is what I have thought:
>
> 1. The setter should be consistent for different kinds of sequences. My
> understanding is that arrays cannot be extended, so I think that it
> should not be able to extend lists either. I think that something like a
> non-destructive `seq-replace` or a non-destructive `seq-splice` is a
> separate feature.

[...]

> 3. The setter should not modify the sequence containing the replacement
> values. The manual states: "All functions defined in this library are
> free of side-effects; i.e., they do not modify any sequence (list,
> vector, or string) that you pass as an argument." I think that it makes
> sense for the setter to modify the target sequence, because `setf` is
> used to set places to values, but I think that it would be unexpected to
> modify the sequence of replacement values and that it would be contrary
> to what the manual states and how the other features behave.

That's a bit of a contradiction, since when using your patch we do
modify the original sequence.  That's a reason why your suggestion
doesn't fit that well into the current seq.el.

But The main question for me is: do we want something like you suggest
in seq.el.  And, if we do, should we then provide this functionality as
a generalized variable.  And if we do offer and advertise this
explicitly, it must be implemented as efficient as possible (which is
not the case now).

But I'm stuck with the first question.  And my gut feeling is a clear
"No".  First, I would not provide this as gv but as a normal function.
There is no necessity to go the gv way.

Second, it doesn't fit into seq.el for the reason you gave: the library
promises not to modify sequences.  This is not cut in stone, of course.


> I will try to find uses of `cl-replace` and maybe uses of `append` and
> `nconc` for examples. Also, I have attached a version of the patch that
> does not compute the length of the list unless needed.

I'm mostly interested in real-life examples where your patch would lead
to simpler, better understandable and better maintainable code; and I
think Stefan, too.

That you need such a functionality for your own code counts but is not
enough of its own.  You surely could modify your macro to do what you
want without changing Emacs.


Michael.





      reply	other threads:[~2024-05-14 15:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01  3:31 bug#68863: Add support for using setf with seq-subseq Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-04 18:33 ` bug#68863: [PATCH] " Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-08 11:39 ` bug#68863: " Eli Zaretskii
2024-02-08 14:25   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-09  3:54     ` Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-14  2:50       ` Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-18  2:54         ` Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-07  1:45           ` Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-08 21:01             ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-09 12:16             ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-09 13:55               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-14 12:47               ` Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-14 15:52                 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]

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=87zfssl7am.fsf@web.de \
    --to=bug-gnu-emacs@gnu.org \
    --cc=68863@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=michael_heerdegen@web.de \
    --cc=monnier@iro.umontreal.ca \
    --cc=nicolas@petton.fr \
    --cc=okamsn@protonmail.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 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.