From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani
Hi Philipp,
nice idea!=C2=A0 I have some questions:
+(pcase-defmacro rx (&rest regexps)
+=C2=A0 "Build a `pcase' pattern matching `rx' regexps.
+The REGEXPS are interpreted as by `rx'.
Should we tell what the semantics of multiple REGEXPS is?=C2=A0 I guess the= y
are implicitly wrapped inside rx-`and' (but FWIW, the doc of `rx' a= lso
fails to tell that).
+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?
+In addition to the usual `rx' constructs, REGEXPS can contain the
+following constructs:
+
+=C2=A0 (let VAR FORM...)=C2=A0 creates a new explicitly numbered submatch<= br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0that matches FORM and binds the match to
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0VAR.
This made me wonder what FORM should be.=C2=A0 I think it means any rx
symbolic expression, so the name FORM seems misleading.
+(ert-deftest pcase-tests-rx ()
+=C2=A0 (should (equal (pcase "a 1 2 3 1 b"
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0((rx = (let u (+ digit)) space
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (let v (+ digit)) space
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (let v (+ digit)) space
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (backref-var u))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (lis= t u v)))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'("= 1" "3"))))
+
I don't understand the example (or test).=C2=A0 Is v first bound to 2, = and
after that rebound to 3?=C2=A0 This seems at least surprising, since let
behaves differently in pcase, e.g.
(pcase 'foo
=C2=A0 ((and (let x 1) (let x 2)) x))
=3D=3D> nil
Hmm, in general I see the risk of confusing this `let' with `pcase'= let.
It seems to be something very different.=C2=A0 Maybe you could just pick a<= br> different name, `bind' maybe?