[GSOC] regular expressions beta is here

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed Aug 10 10:45:16 PDT 2011


On 8/10/11 10:46 AM, Jacob Carlborg wrote:
> On 2011-08-10 17:55, Dmitry Olshansky wrote:
>> On 10.08.2011 18:54, Jacob Carlborg wrote:
>>>> Interesting idea, one problem with it is that I want this:
>>>>
>>>> auto m = match("bleh", "bleh");
>>>> writeln(m);
>>>>
>>>> to actually print "bleh", not true
>>>> Right now due to a carry over bug from std.regex (interface thing)
>>>> writln(m) will just do a stackoverflow, m.hit however works.
>>>
>>> No, that won't be any problem:
>>>
>>> struct Foo
>>> {
>>> bool b;
>>> alias b this;
>>> }
>>>
>>> auto f = Foo();
>>> static assert(is(typeof(f) == Foo));
>>>
>>> The above assert passes as expected.
>> That may be all well, but try writeln on it, what will it print?
>
> Hmm, it doesn't print anything, I think it looks like a bug in writeln.
>
>> After some experience with alias this I had to conclude that it's rather
>> blunt tool, and I'd rather stay away of it.
>> Actually I like Steven's opCast suggestion, so that it works in
>> conditionals.
>
> Oh, I didn't know that it would work implicitly in conditionals. Then
> I'm happy with opCast :)

That's pretty cool actually because it naturally extends the built-in 
approach. When you do e.g. if (pointer) that's really equivalent to if 
(cast(bool) pointer) and so on.

Andrei


More information about the Digitalmars-d mailing list