GNU bug report logs -
#78704
[PATCH] Use `seq-do' instead of `seq-map' for side-effects
Previous Next
Full log
View this message in rfc822 format
"Eli Zaretskii" <eliz <at> gnu.org> writes:
>> Date: Thu, 05 Jun 2025 23:18:26 -0400
>> From: Zach Shaftel via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>>
>> self explanatory i think.
>
> I'm not sure it is, but I added a few people who might have an
> opinion.
First of all, this is a good catch! The situation is similar for map-do
/ map-apply, including a usage in radix-tree.el which may not be
reported by the byte compiler.
But I'm not sure adding important-return-value to functions which aren't
usually side-effect-free is a good idea given the warnings it currently
produces.
The main reason is that it's not a helpful warning unless we tell the
user which function to use instead: mapc is a special case which is
handled by an explicit message, but without a "use `seq-do' instead"
in the message, fixing the warning requires looking up docstrings to
find the right alternative, which might not exist.
Some other languages have chosen a different approach and provide a way
for functions to know, at compile time or run time, whether their return
value is used in a particular call. Maybe we should do that instead?
As an analogy, the byte compiler won't complain about (equal x 3), but
will silently replace it by (eq x 3), so it's not like we always warn
the user about code which can be optimized in a similar fashion.
However, I did notice that we warn about fewer important-return-value
functions than I thought, and opened bug#78716 to discuss whether we
should add more warnings.
Pip
This bug report was last modified 8 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.