Subject: bug#6384: Teach rx explicitly numbered submatches

From: Lennart Borgman <[email-masked]>
Date: Thu, 10 Jun 2010 18:21:36 +0200

On Thu, Jun 10, 2010 at 5:51 PM, Juri Linkov <[email-masked]> wrote:
>>      (submatch                . (rx-submatch 1 nil)) ; SRE
>> +    (submatch-n              . (rx-submatch-n 2 nil))
>
> I think better would be to allow the existing subform `submatch'
> to support numbered groups, i.e. in addition to the current form
> `(submatch SEXP1 SEXP2 ...)' also support
> `(submatch N SEXP1 SEXP2 ...)' because the number is a parameter
> of normal groups.
>
> There are already subforms that support different number of integer
> arguments like `(repeat N SEXP)' and `(repeat N M SEXP)'.  So the same
> could be done for `submatch' too.

I thought of that, but currently you can do

  (rx (submatch 1 "str"))

Should perhaps 1 etc be disallowed as SEXP:s in rx? (I do not know how
to do it because I believe rx uses `read'.)