unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: 27659@debbugs.gnu.org, Tino Calancha <tino.calancha@gmail.com>
Subject: bug#27659: 26.0.50; Add string-matched-text: string-match + match-string
Date: Sun, 23 Jul 2017 20:45:34 +0000	[thread overview]
Message-ID: <CAArVCkQXedzbDwXK3sc16QYsRs8wsOMDeUJ36c1aCHbWa3q63w@mail.gmail.com> (raw)
In-Reply-To: <87mv7x451o.fsf@drachen>

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

Michael Heerdegen <michael_heerdegen@web.de> schrieb am Sa., 22. Juli 2017
um 03:46 Uhr:

> Hi Philipp,
>
> nice idea!  I have some questions:
>
>
> +(pcase-defmacro rx (&rest regexps)
> +  "Build a `pcase' pattern matching `rx' regexps.
> +The REGEXPS are interpreted as by `rx'.
>
> Should we tell what the semantics of multiple REGEXPS is?  I guess they
> are implicitly wrapped inside rx-`and' (but FWIW, the doc of `rx' also
> fails to tell that).
>


yes, probably something should be added to the docstring of `rx'.


>
>
> +Within the case code, the match data is bound as usual, but you
>
> This makes it sound like match data is bound pcase-branch-locally.
> This isn't the case, right?
>

Yes, I've reworded it to sound less like a variable binding.


>
>
> +In addition to the usual `rx' constructs, REGEXPS can contain the
> +following constructs:
> +
> +  (let VAR FORM...)  creates a new explicitly numbered submatch
> +                     that matches FORM and binds the match to
> +                     VAR.
>
> This made me wonder what FORM should be.  I think it means any rx
> symbolic expression, so the name FORM seems misleading.
>

I think the words `form' and `sexp' are used mostly interchangeably
nowadays, and the docstring of `rx' speaks of "forms" several times.


>
>
> +(ert-deftest pcase-tests-rx ()
> +  (should (equal (pcase "a 1 2 3 1 b"
> +                   ((rx (let u (+ digit)) space
> +                        (let v (+ digit)) space
> +                        (let v (+ digit)) space
> +                        (backref-var u))
> +                    (list u v)))
> +                 '("1" "3"))))
> +
>
> I don't understand the example (or test).  Is v first bound to 2, and
> after that rebound to 3?  This seems at least surprising, since let
> behaves differently in pcase, e.g.
>
> (pcase 'foo
>   ((and (let x 1) (let x 2)) x))
> ==> nil
>
> Hmm, in general I see the risk of confusing this `let' with `pcase' let.
> It seems to be something very different.  Maybe you could just pick a
> different name, `bind' maybe?
>
>
>
I'd rather stick with the short and common `let'. That there's a name clash
is unfortunate, but there are lots of similar cases (e.g. pcase `let' vs.
Lisp `let', rx `and' and `or').

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

  reply	other threads:[~2017-07-23 20:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-12  6:13 bug#27659: 26.0.50; Add string-matched-text: string-match + match-string Tino Calancha
2017-07-20  0:54 ` Drew Adams
2017-07-20  1:19   ` Tino Calancha
2017-07-20 19:51 ` Philipp Stephani
2017-07-21 12:29   ` Tino Calancha
2017-07-21 13:34     ` Stefan Monnier
2017-07-21 14:08       ` Tino Calancha
2017-07-21 23:28       ` John Mastro
2017-07-22  2:02         ` Michael Heerdegen
2017-07-23 20:41       ` Philipp Stephani
2017-07-24 14:30         ` Stefan Monnier
2017-07-22  1:46   ` Michael Heerdegen
2017-07-23 20:45     ` Philipp Stephani [this message]
2017-07-23 21:39       ` Michael Heerdegen

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=CAArVCkQXedzbDwXK3sc16QYsRs8wsOMDeUJ36c1aCHbWa3q63w@mail.gmail.com \
    --to=p.stephani2@gmail.com \
    --cc=27659@debbugs.gnu.org \
    --cc=michael_heerdegen@web.de \
    --cc=tino.calancha@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 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).