earthquake changes of std.regexp to come

Chris Nicholson-Sauls ibisbasenji at gmail.com
Tue Feb 17 16:22:12 PST 2009


Jarrett Billingsley wrote:
> On Tue, Feb 17, 2009 at 3:16 PM, BCS <ao at pathlink.com> wrote:
>> could this be transitioned to CTFE? you could even have a debug mode that
>> delays till runtime
>>
>> RegEx mather = new CTFERegEx!("some regex");
>>
>>
>> class CTFERegEx(char[] regex) : RegEx
>> {
>>      debug(NoCTFE)  static char[] done;
>>      else     static const char[] done = CTFECompile(regex);
>>
>>      public this()
>>      {
>>         debug(NoCTFE) if(done == null) done = CTFECompile(regex);
>>
>>         base(done)
>>      }
>> }
> 
> For what it's worth the Tango regexes actually have a method to output
> a D function that will implement the regex after it's compiled.  So
> you _could_ precompile the regex into D code and use that.

I feature which I *adore* by the way.  So long as the precompiled regex 
is "guaranteed" to run at best possible performance (hand-rolled, 
hand-optimized solutions notwithstanding) I for one prefer them.

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list