Duy Nguyen
unread,Apr 9, 2020, 5:03:48 AM4/9/20Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to chibi-...@googlegroups.com, Arthur A. Gleckler
This was posted in srfi-115 list, but I hope to catch Alex's attention
by doing it here instead.
'subst' parameter of regexp-replace is described like this
---
subst can be a string, an integer or symbol indicating the contents of
a numbered or named submatch of re, 'pre for the substring to the left
of the match, or 'post for the substring to the right of the match.
---
This makes replacement very limited. I found that chibi.regex accepts
'subst' as a _list_ of those items too. With that we can start doing
something like this regexp
s/\(<first>\)...\(<second>\)/blah \2 - \1/'
The SRFI should probably mention that it is an error if a capture
group is named 'pre or 'post because it's ambiguous. Each Scheme
implementation can decide whatever they want to do in that case.
Also, 'subst' can be a procedure in chibi.regex and that makes
replacement much more flexible.
Is it reasonable to amend the SRFI like above? As far as I know, all
srfi-115 implementations out there are based on chibi.regex, which
already supports that. The only exception is Gauche, which translates
SRE to its own AST syntax, and I made sure that it supports the same.
If the SRFI is set in stone, I think we could make a new one and let
it be voted to replace srfi-115 in r7rs-large.
--
Duy