unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: 50136@debbugs.gnu.org, monnier@iro.umontreal.ca
Subject: bug#50136: 28.0.50; A problem with rx-let expansion
Date: Fri, 20 Aug 2021 17:23:58 +0200	[thread overview]
Message-ID: <A0D3A614-BCC2-43EB-BB99-E9B63C4CD8EB@acm.org> (raw)
In-Reply-To: <878s0wcj3j.fsf@web.de>

20 aug. 2021 kl. 15.59 skrev Michael Heerdegen <michael_heerdegen@web.de>:

> (rx-let ((scatter (string)
>                  (regex (mapconcat #'string (string-to-list string) ".*"))))
>  (rx (scatter "abc"))) => useless error message

Yes, that's an unfortunate consequence of the current substitution mechanism (validating Stefan's premonitions to some extent).
However the syndrome is entirely avoidable and does not make the facility less powerful.

> Personally I would be more happy with a thing called `rx-macrolet' than
> with an extended `rx-let' to support this additional macro-like kind of
> syntax.

Noted (in the honest sense)!

> AFAIU, the current approach doesn't allow to extend this with an
> optional CHARS argument to specify with chars are allowed "in between"
> (instead of "any").  The "&optional" keyword makes it barf.

That's right. What would be the preferred semantics? For example, what value would you expect an absent optional parameter to take? `nil` isn't very useful inside rx forms, so it would only make sense inside embedded Lisp expressions.

> And I can't actually "look" at the arguments to provide a conditional
> replacement.  All I can do is to use `regex' to eval a constant
> expression I specify (at run-time).  This seems a quite limiting
> approach.  Something more macro-like would be appropriate IMO.

Actually it's the rx `eval` form that you are looking for if you want arbitrary compile-time computation. `regexp` and `literal` are explicitly made for run-time expressions.






  parent reply	other threads:[~2021-08-20 15:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20 13:59 bug#50136: 28.0.50; A problem with rx-let expansion Michael Heerdegen
2021-08-20 14:50 ` Michael Heerdegen
2021-08-20 15:23 ` Mattias Engdegård [this message]
2021-08-20 17:21   ` Michael Heerdegen
2021-08-20 18:45     ` Mattias Engdegård
2021-08-21 11:45       ` Michael Heerdegen
2021-08-21 13:02         ` Mattias Engdegård
2021-08-23 10:45           ` Michael Heerdegen
2021-08-23 12:38             ` Mattias Engdegård
2021-08-23 15:20             ` Mattias Engdegård
2021-08-23 16:59               ` Michael Heerdegen
2021-08-23 18:05                 ` Mattias Engdegård
2021-08-21  3:21     ` Richard Stallman

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=A0D3A614-BCC2-43EB-BB99-E9B63C4CD8EB@acm.org \
    --to=mattiase@acm.org \
    --cc=50136@debbugs.gnu.org \
    --cc=michael_heerdegen@web.de \
    --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).