[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Effect of string mutation on submatch extraction

This page is part of the web mail archives of SRFI 115 from before July 7th, 2015. The new archives for SRFI 115 contain all messages, not just those from before July 7th, 2015.

On Fri, Nov 15, 2013 at 5:44 PM, Evan Hanson <evhan@xxxxxxxxxxxxxxx> wrote:

After removing the string arguments from the submatch extraction
procedures, should the results of things like the following be

    (define s "abc")
    (define m (regexp-search "b" s))
    (regexp-match-submatch m 0) ; => "b"
    (string-set! s 1 #\B)
    (regexp-match-submatch m 0) ; => "b", "B", or undefined?

Chibi returns "B", which I also think is the better option since it's
simpler and probably more efficient, though "b" is arguably nicer for
the user. Either way, is it worth specifying one (even if that's just

A very good point, I think we should explicitly
state this is undefined.

I had also been planning on noting that the
effects of mutating an SRE passed to `regexp'
is undefined.  The cost of making a full copy of
every compilation is too expensive, especially
when considering huge mutable Unicode char-sets.