unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Andy Moreton <andrewjmoreton@gmail.com>
To: 20268@debbugs.gnu.org
Subject: bug#20268: 25.0.50; pcase-lambda broken
Date: Wed, 08 Apr 2015 14:22:46 +0100	[thread overview]
Message-ID: <vz1bniy3gbd.fsf@gmail.com> (raw)
In-Reply-To: <m2zj6k5qqf.fsf@gmail.com>

On Tue 07 Apr 2015, Stefan Monnier wrote:

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

Please improve the documentation for the pcase macros:

 a) The elisp manual has reference documentation for pcase, but it is
    confusing and short on examples. The first example would be clearer
    if it was more like the second example, by showing some example
    forms that invoke pcase and the result of evaluating them.

    The description would flow more logically if the second example
    followed the reference that describes the allowed patterns, and 
    included an example of each type of pattern.

 b) Add meaningful help strings for pcase-lambda, pcase-let* and
    pcase-let. The existing help strings all say that these constructs
    are "the same as another thing only different" which only serves to
    obscure what they do. A user should be able to discern what the
    interface contract is without reading the implementation. A short
    motivating example for each macro would be helpful.

These improvements would make code using the pcase macros more readable,
and aid understanding of the intended semantics.

    AndyM






  reply	other threads:[~2015-04-08 13:22 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 [this message]
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=vz1bniy3gbd.fsf@gmail.com \
    --to=andrewjmoreton@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).