Fixing the API of std.regex
Dmitry Olshansky
dmitry.olsh at gmail.com
Tue Mar 12 06:12:42 PDT 2013
12-Mar-2013 14:36, Andrej Mitrovic пишет:
> On 3/12/13, Dmitry Olshansky <dmitry.olsh at gmail.com> wrote:
>> struct match //ditto for replace
>> {
>> //current behavior
>> static auto opCall(.....);
>> }
>
> For a second I was worried this would break UFCS, but actually it
> still works. Pretty kewl.
>
Actually it does... but only partially:
struct match //ditto for replace
{
//current behavior
static void opCall(T)(T s)
{
writeln(s);
}
//get the first match / replace only first occurance
static void first(T)(T s, int k)
{
writelen("FIRST: ", s);
}
// force to find all matches (still lazy range) and
static void all(T)(T s, int p)
{
writlen("ALL: ", s);
}
}
void main()
{
"abc".match(); //works
"abc".match.first(42); //doesn't
}
There's got to be some way out of it that doesn't involve alias this and
proxies...
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list