From: Noam Postavsky <npostavs@gmail.com>
To: "Clément Pit-Claudel" <clement.pitclaudel@live.com>
Cc: Michael Heerdegen <michael_heerdegen@web.de>, 31715@debbugs.gnu.org
Subject: bug#31715: cl-incf and cl-decf error out when passed a nil-valued variable as 'offset'
Date: Tue, 05 Jun 2018 18:53:29 -0400 [thread overview]
Message-ID: <87k1rc7sly.fsf@gmail.com> (raw)
In-Reply-To: <bae46622-25a7-a949-f965-021e8e965b5c@live.com> ("Clément Pit-Claudel"'s message of "Tue, 5 Jun 2018 11:19:22 -0400")
Clément Pit-Claudel <clement.pitclaudel@live.com> writes:
> On 2018-06-04 18:58, Noam Postavsky wrote:
>> X is an optional macro parameter, so the "optionalness" applies at
>> compile time.
>
> I think I see what you mean, but I'm not entirely convinced (in part
> because the docstring doesn't say so, and in part because it doesn't
> seem worth it to break referential transparency: if we accept nil, we
> should also accept a variable that evaluates to nil).
Hmm, not sure if referential transparency makes much sense for macros.
Both SBCL and CLisp throw an error for (let ((x 1) (y nil)) (incf x y)),
although I can't see anything in the Common Lisp spec to decide either
way. E.g., cltl2 says:
If delta is not supplied, then the number in place is changed by 1.
https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node125.html
>> I think that would approximately double the cost of cl-incf in the
>> simple case. And since you would expect cl-incf to be used in loops a
>> lot, that seems like a bad idea.
>
> I think we could still optimize the case in which we get an explicit nil.
As I wrote earlier, I was wrong about the optimization thing anyway (I
initially looked at the macro expansion output instead of the byte
compiler output).
> In the rest of Emacs there are lots of other examples. Many of them
> (for example semantic-find-tags-by-name or calendar-increment-month)
> seem to work when passed a nil-valued variable, but many others behave
> like cl-incf (for example gnus-summary-article-score).
I don't think those are great examples of macros to emulate.
semantic-find-tags-by-name and gnus-summary-article-score look like they
should be (inline?) functions instead of macros.
calendar-increment-month doesn't use make-symbol for proper temp
variable hygiene.
next prev parent reply other threads:[~2018-06-05 22:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-04 20:06 bug#31715: cl-incf and cl-decf error out when passed a nil-valued variable as 'offset' Clément Pit-Claudel
2018-06-04 22:58 ` Noam Postavsky
2018-06-04 23:43 ` Michael Heerdegen
2018-06-05 0:12 ` Noam Postavsky
2018-06-05 0:40 ` Michael Heerdegen
2022-04-21 13:11 ` Lars Ingebrigtsen
2018-06-05 15:19 ` Clément Pit-Claudel
2018-06-05 22:53 ` Noam Postavsky [this message]
2018-06-05 23:01 ` Clément Pit-Claudel
2018-06-05 23:26 ` Noam Postavsky
2018-06-05 23:36 ` Clément Pit-Claudel
2018-06-06 0:32 ` Michael Heerdegen
2018-06-06 0:37 ` Noam Postavsky
2018-06-05 15:03 ` Clément Pit-Claudel
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=87k1rc7sly.fsf@gmail.com \
--to=npostavs@gmail.com \
--cc=31715@debbugs.gnu.org \
--cc=clement.pitclaudel@live.com \
--cc=michael_heerdegen@web.de \
/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.