chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] irregex-replace return value


From: Alex Shinn
Subject: Re: [Chicken-users] irregex-replace return value
Date: Sun, 2 Mar 2014 17:40:02 +0900

Hi Michele,

On Sat, Mar 1, 2014 at 7:32 AM, Michele La Monaca <address@hidden> wrote:
Hi,

I've noticed that irregex-replace returns the original string
if no replacement takes place. I think its a very poor choice.

Whether or not a replacement was actually made can be an important
piece of information which is lost returning the original string.
The "correct" return value should be #f.

Ditto irregex-replace/all.

I've used irregex-replace{,/all} and equivalents in other
languages for a long time, and find the current semantics
most convenient.  I can see in some cases wanting to test
for a replacement, or in irregex-replace-all the number of
replacements, but it seems to be by far the rarer case
(varying with individual programming style).

Your options right now in these cases are to test for the
match then apply the subst manually, or write a utility to
do so.

If you're interested, there's also SRFI 115 currently under
discussion for standard Scheme regular expressions.

-- 
Alex


reply via email to

[Prev in Thread] Current Thread [Next in Thread]