all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 51368@debbugs.gnu.org
Subject: bug#51368: 29.0.50; `cl-case' should error on incorrect use
Date: Sun, 31 Oct 2021 19:53:53 +0100	[thread overview]
Message-ID: <CAArVCkTdO+mEU9g-shQfiq3_WncTf56zPtMWLc=goSERgh0=Cw@mail.gmail.com> (raw)
In-Reply-To: <87a6iy71q1.fsf@gnus.org>

Am So., 24. Okt. 2021 um 19:48 Uhr schrieb Lars Ingebrigtsen <larsi@gnus.org>:
>
> Philipp Stephani <p.stephani2@gmail.com> writes:
>
> > This form demonstrates a few incorrect uses of `cl-case':
> >
> > (cl-case a
> >   (nil 0)   ; doesn't match anything
> >   (t 1)     ; matches everything, but too early
> >   ('foo 2)) ; matches `quote' in addition to `foo'
> >
> > It would be nice if `cl-case' would signal an error or at least warn
> > about these at macroexpansion time, since they are somewhat subtle and
> > easy to get wrong.
>
> An error from the second case would be nice, and a warning on the first
> case, but the third case:
>
> (macroexpand
>  '(cl-case a
>     ('foo (message "foo"))))
> => (cond ((cl-member a ''foo) (message "foo")))
>
> and
>
> (equal ''foo (list 'quote 'foo))
>
> which, sure, whatever.  But I guess the question is whether we can
> actually warn about that, because to the reader, the two forms are
> equivalent?

Yes, but the problem only arises if the user wants to match the symbol
`quote' plus exactly one other value. That should already be
exceedingly rare, and can be trivially rewritten by swapping the two
values (i.e. write (foo quote) instead of (quote foo)). So I think
issuing a warning or error for that case is worth it.
Assuming we'd want to prevent similar bugs with other reader
constructs, I think the only real problematic case is matching exactly
two of the symbols `function', `quote', `,', `,@', and `\`'. Maybe for
those cases we should just instruct people to write (cond (memq ...))
or similar.





  reply	other threads:[~2021-10-31 18:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-24  7:52 bug#51368: 29.0.50; `cl-case' should error on incorrect use Philipp Stephani
2021-10-24  8:16 ` Andreas Schwab
2021-10-24 12:46   ` Stefan Kangas
2021-10-24 17:48 ` Lars Ingebrigtsen
2021-10-31 18:53   ` Philipp Stephani [this message]
2021-11-01 13:31     ` Lars Ingebrigtsen
2021-11-12 19:34       ` Philipp Stephani
2021-11-14  1:09         ` Lars Ingebrigtsen
2021-11-14 15:08         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-13 15:19           ` Lars Ingebrigtsen
2022-09-13 16:12             ` Lars Ingebrigtsen
2022-09-13 16:15               ` Lars Ingebrigtsen
2023-09-03  8:48             ` Stefan Kangas
2022-10-02 21:39 ` Göktuğ Kayaalp
2023-09-03 13:40 ` Mattias Engdegård
2023-10-01 17:03   ` Stefan Kangas

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='CAArVCkTdO+mEU9g-shQfiq3_WncTf56zPtMWLc=goSERgh0=Cw@mail.gmail.com' \
    --to=p.stephani2@gmail.com \
    --cc=51368@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    /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.