Subject: Re: 28.0.50; A problem with rx-let expansion

From: Michael Heerdegen <[email-masked]>
Date: Mon, 23 Aug 2021 18:59:11 +0200

Mattias Engdegård <[email-masked]> writes:

> Here is my proposed change to the manual. I didn't change the doc
> strings since they already refer to that Info node.

Maybe at least one sentence about that this mechanism just performs
trivial substitution?

> +User-defined forms themselves only perform simple template
> +substitution.

I find the term "user-defined" distracting, because anybody (including
library and package developers) is "affected".  Apart from that, ok for
me.

>  For arbitrary computations, use them together with with
> +the @code{rx} forms @code{eval}, @code{regexp} or @code{literal}.
> +Example:
> +
> +@example
> +@group
> +(defun n-tuple-rx (n element)
> +  `(seq "<"
> +        (group-n 1 ,element)
> +        ,@@(mapcar (lambda (i) `(seq ?, (group-n ,i ,element)))
> +                  (number-sequence 2 n))
> +        ">"))
> +(rx-define n-tuple (n element) (eval (n-tuple-rx n 'element)))
> +(rx (n-tuple 3 (+ (in "0-9"))))
> +  @result{} "<\\(?1:[0-9]+\\),\\(?2:[0-9]+\\),\\(?3:[0-9]+\\)>"
> +@end group
> +@end example
>  @end defmac

Didn't try the example, but it looks good.

I have one more thing, however, once we are here: In the docstring of
`rx', near the end:

| (eval EXPR)    Match the rx sexp from evaluating EXPR at compile time.

can we say "expansion time" instead of "compile time"?

Regards,

Michael.