all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>, Leo Liu <sdl.web@gmail.com>
Cc: 20268@debbugs.gnu.org
Subject: bug#20268: 25.0.50; pcase-lambda broken
Date: Wed, 08 Apr 2015 15:08:36 +0000	[thread overview]
Message-ID: <CAArVCkQsn7eQ4Ffag3a-xf3JDyP6OTEfw42eNSqgq+2AKeZKWA@mail.gmail.com> (raw)
In-Reply-To: <jwv6197v024.fsf-monnier+emacsbugs@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1635 bytes --]

Stefan Monnier <monnier@iro.umontreal.ca> schrieb am Mi., 8. Apr. 2015 um
04:15 Uhr:

> > After the recent rewrite, pcase-lambda is broken. For example, eval the
> > following to get 46422 instead of the correct value 65535.
>
> >    (cl-some (pcase-lambda (`[fullsweep_after ,v]) v)
> >             '([min_bin_vheap_size 46422]
> >               [min_heap_size 233]
> >               [fullsweep_after 65535]
> >               [minor_gcs 40]))
>
> Indeed, that's the semantics I chose.
> The previous semantics was for the function to do nothing and return nil
> if the arg doesn't match.  The new semantics is the same as the one used
> by pcase-let.  It's not without its fault of course, but at least it does
> correspond to the usual idea of "destructuring" and generates more
> efficient code.
>
> I think if you prefer to return nil, then the macro should look like
>
>    (pcase-lambda ((`[fullsweep_after ,v]) v))
>
> which would then naturally let you add additional cases like
>
>    (pcase-lambda ((`[fullsweep_after ,v]) v)
>                  ((`[min_heap_size ,v]) (/ v 2)))
>
> Admittedly, for the current pcase-lambda (and pcase-let) macro, the
> pcase.el code should be refined so as to emit a warning when it ends up
> ignoring a constant like `fullsweep_after' above.
>
>
Why not raise an error instead if there is no match (or even if any quoted
or self-quoting expressions are used at all)? The current behavior is quite
confusing, and warnings tend to be ignored.

Given that pcase-let, pcase-lambda and pcase-dolist don't do any
case-by-case analysis, maybe they should even be renamed and moved out of
pcase.el.

[-- Attachment #2: Type: text/html, Size: 2114 bytes --]

  parent reply	other threads:[~2015-04-08 15:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07  7:42 bug#20268: 25.0.50; pcase-lambda broken Leo Liu
2015-04-08  1:01 ` Leo Liu
2015-04-08 14:35   ` Stefan Monnier
2015-04-08  2:14 ` Stefan Monnier
2015-04-08 13:22   ` Andy Moreton
2015-04-08 15:08   ` Philipp Stephani [this message]
2015-04-08 19:25     ` Stefan Monnier
2015-04-08 20:31       ` Drew Adams
2015-04-08 21:29         ` Stefan Monnier
2015-04-08 22:21           ` Drew Adams
2022-02-08  7:52   ` Lars Ingebrigtsen

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=CAArVCkQsn7eQ4Ffag3a-xf3JDyP6OTEfw42eNSqgq+2AKeZKWA@mail.gmail.com \
    --to=p.stephani2@gmail.com \
    --cc=20268@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=sdl.web@gmail.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.