From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-09-04 20:06:36
"Eric Niebler" <eric_at_[hidden]> wrote in message
> Jonathan Turkanis wrote:
> > - Have you considered allowing format strings to be bound statically?
> That hadn't occured to me. Certainly possible, but I think the returns
> would be small. The complexity of doing string replacements is linear,
> and so is not as sensitive to optimization as pattern matching. And the
> format string has very simple syntax, so static syntax checking isn't as
> big of a win here, either.
> > - Have you considered using _1, _2, _3 instead of s1, ... for capturing
> > paretheses? You could also use them as placeholders in statically-bound
> > strings.
> Yes, I used _1, _2, _3 for a long time. I abandoned it because of name
> conflicts with the identically-named placeholders from other boost
I know this problem well :(
> I picked s1, s2, ... for two reasons:
> 1) The "s" in "s1" stands for "sub-match", which is what these thigs
> 2) s1 kind of looks like $1, which is the perl equivalent.
I didn't think of 2). Did you put in in the docs? FWIW, capital 'S' looks more
like '$' to me. E.g.,
'<' >> (S1= +_w) >> '>' >> -*_ >> "</" >> S1 >> '>'
> That said, I'm open to suggestions for avoiding the name conflicts. I
> would consider switching back to _1 _2 _3 if the technical problems were
> overcome and if people liked it better.
May I assume you have considered reusing the placeholders from boost::bind?
There doesn't seem to be much operator overloading involving boost::arg<>.
> > - have you considered overloading operator/ to emulate perl syntax for
> > substitution. E.g.,
> > s/expr/fmt,
> > sub/expr/fmt, or just
> > expr/fmt
> > could return a function object with templated operator which invokes
> > regex_replace.
> A little too cute, IMO.
Oh well ;-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk