unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Leo Liu <sdl.web@gmail.com>
To: 20268@debbugs.gnu.org
Subject: bug#20268: 25.0.50; pcase-lambda broken
Date: Wed, 08 Apr 2015 09:01:13 +0800	[thread overview]
Message-ID: <m1twwrcu1y.fsf@zeuss-MBP.lan> (raw)
In-Reply-To: <m2zj6k5qqf.fsf@gmail.com> (Leo Liu's message of "Tue, 07 Apr 2015 15:42:32 +0800")

Forgive me to rely here. None of our messages shown up in bug#19670.

> After recent rewrite of pcase-lambda I am seeing:

> (cl-some (pcase-lambda (`[fullsweep_after ,v]) v)
>         '([min_bin_vheap_size 46422]
>           [min_heap_size 233]
>           [fullsweep_after 65535]
>
>           [minor_gcs 10]))
>
> 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 don't mind new semantics but I want to make sense of it so as to use
it with confidence. What I am seeing is:

(funcall (pcase-lambda (`[fullsweep_after ,v]) v) [min_bin_vheap_size 46422])

=> 46422

That doesn't make sense to me. Could you explain why this is the right
thing?

> 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)))

I didn't choose the multiple-clause version because it is a cheap
shortcut for (lambda (...) (pcase ... ...)).

The single-clause pcase-lambda makes a lot of higher-order functions fun
to use and that is where I am reaping the benefits.

> 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.

Yes, I am having a lot of trouble understanding and using pcase-let*
except for trivial cases. I don't want the same thing to happen to
pcase-lambda.

>        Stefan

Thanks,
Leo





  reply	other threads:[~2015-04-08  1:01 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 [this message]
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
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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m1twwrcu1y.fsf@zeuss-MBP.lan \
    --to=sdl.web@gmail.com \
    --cc=20268@debbugs.gnu.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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).