Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-10-23 11:13:46


"Eric Niebler" <eric_at_[hidden]> wrote in message
news:41798CEF.4040807_at_boost-consulting.com...
>
> Jonathan Turkanis wrote:
> > <Schalk_Cronje_at_[hidden]> wrote in message:
> >
> >
> >>Would anyone be interested in having a perl-like regex shortcut notation?
>
> <snip>
>
> >>// [1] Substitutes first occurrence and copy (calls boost::regex_replace)
> >>// perl: ($s2=$str) =~ s/(BLAH)/Hooray/;
> >>std::string s2= _s / "(BLAH)" / "Hooray" / str;
> >
> >
> > Something like this would fit in easily with Eric Niebler's xpressive
> > library. In fact, I suggested it, but Eric said it was "too cute". Perhaps
> > we should convene a focus group to discuss the subject. ;-)

It looks like the focus group is now in session ;-)

> >
>
> In fact, you could use almost completely emulate perl syntax if you want to:
>
> string str = ...;
> sregex rex = ...;
>
> str ^= _s/rex/"c++ sux, perl rulz!!"/_g;

This is closer to what I had in mind originally. Unfortunately (or fortunately,
if you want to poke holes in the idea), you don't get the closing slash unles
flags are provided. (Flag _e would be particularly interesting.)

> It's certainly cute, and it would be an interesting exersice. It is also
> not particularly appealing to me, since the only reason I wrote a C++
> regex engine in the first place was because I strongly disliked perl's
> syntax. And to me, it seems less like a domain-specific embeded language
> than like simply trying to write perl in C++

So you won't be contributing to the Boost.Perl library which I'm planning to
write as soon as ISO Perl is complete? ;-)

> -- an endeavor of dubious
> value.

I basically agree with your analysis, which is why I didn't press the issue.

Jonathan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk