Subject: bug#58727: 29.0.50; rx doc: Semantics of RX...

From: Mattias Engdegård <[email-masked]>
Date: Mon, 24 Oct 2022 14:49:25 +0200

24 okt. 2022 kl. 04.34 skrev Michael Heerdegen <[email-masked]>:

>> The rule is implicit concatenation unless specified otherwise; maybe
>> we could say that in the leading paragraph. (`or` is the only place
>> where concatenation isn't done.)
> 
> Yes, that would be good.

Now added.

> I meant the implicit shy
> grouping added in the return value

Yes, and this is simply not a problem in rx, nor on the abstract regexp level -- it's just a feature of the surface syntax of string regexps but that's not something that the rx docs are or should be preoccupied with.

(For that matter, 'shy grouping' is terrible terminology: it's obscure wording for something that is generally known as bracketing to the general population.)

>  (rx (or "ab" "cd")) ==> "\\(?:ab\\|cd\\)"
>                           ^^^^^       ^^^

This happens to be a cosmetic flaw in rx: in this case the brackets shouldn't be there at all, but getting rid of them is currently more trouble than it's worth. It does not affect matching performance. See it as an excess of packaging material which does not increase the shipping costs.

>> The manual provides corresponding string-notation constructs for
>> orientation only.  This is important -- rx forms are defined by their
>> semantics, not by what strings they translate to.
> 
> Is this trivial however?  Is it clear that, even for people that see rx
> more as a translator to stringish regexps, `rx' is that smart?

It's not that rx is smart, it's that it's not completely broken. Mentioning that rx adds brackets now and then is tantamount to saying that it's not buggy. 

We don't say that the byte-compiler emits jump instructions as needed, not just because it's superfluous information but also because such a statement suggests that it's not.

> A sentence like "rx forms are defined by their semantics" would help to
> make that clear I think.

Well, I added a phrase to that effect as well.

Thank you for your comments and suggestions!