unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: master ea93326: Add `union' and `intersection' to rx (bug#37849)
Date: Fri, 13 Dec 2019 18:43:47 +0100	[thread overview]
Message-ID: <8D6E2D8D-4617-4EFA-9E60-F5C7B443C24C@acm.org> (raw)
In-Reply-To: <jwvo8wcrw43.fsf-monnier+emacs@gnu.org>

13 dec. 2019 kl. 18.13 skrev Stefan Monnier <monnier@iro.umontreal.ca>:

>    (rx-define-charset ident-chars "a-z0-9")
>    (rx-define-charset op-chars (union "+*/" ?-))
> 
> and then
> 
>     ... (any (union ident-chars op-chars)) ...
> 
> Is it worth the trouble?

Not if a special set of definition constructs are required, no.

> We could try and automatically determine inside `or` when regexp-opt can
> be used.  That doesn't sound like much fun, tho.

That is done now, to some extent. Some history, for those not keeping up:

(or STRING1 STRING2 ...) did use regexp-opt for some time, but it had the unfortunate effect that the match order wasn't preserved, which made the outcome unpredictable. For example, if the target string is "abc", then (or "a" "ab") would match "ab", but (or "a" "ab" digit) would match "a".

The code was then changed to only use regexp-opt when it doesn't affect observed behaviour, which is what we have today.

However, typically the longest match is desired, not the first. The user can order his strings carefully before putting them inside an 'or', but that (1) doesn't compose well, (2) is error-prone, (3) useless manual work that is done by regexp-opt anyway.

Something like (longest-or STRING...) has been proposed, but was not well received. A solution is still sought (preferably one that doesn't involve rewriting the regexp engine).




  reply	other threads:[~2019-12-13 17:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20191210213842.5388.30110@vcs0.savannah.gnu.org>
     [not found] ` <20191210213843.EB6A520A23@vcs0.savannah.gnu.org>
2019-12-10 21:52   ` master ea93326: Add `union' and `intersection' to rx (bug#37849) Stefan Monnier
2019-12-11 11:17     ` Mattias Engdegård
2019-12-11 15:10       ` Stefan Monnier
2019-12-12 22:48         ` Mattias Engdegård
2019-12-13 13:55           ` Stefan Monnier
2019-12-13 17:03             ` Mattias Engdegård
2019-12-13 17:13               ` Stefan Monnier
2019-12-13 17:43                 ` Mattias Engdegård [this message]
2019-12-13 23:03                   ` Stefan Monnier
2019-12-15 11:08                     ` Mattias Engdegård
2019-12-15 14:53                       ` Stefan Monnier
2019-12-15 19:23                         ` Mattias Engdegård
2019-12-15 20:04                           ` Stefan Monnier
2019-12-15 20:42                             ` Stefan Monnier

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=8D6E2D8D-4617-4EFA-9E60-F5C7B443C24C@acm.org \
    --to=mattiase@acm.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).