compile-time regex redux

BCS ao at pathlink.com
Thu Feb 8 07:56:35 PST 2007


Reply to Kenny,

> BCS wrote:
> 
>> As I see it the biggest problem with compile time parsing in D is
>> that building non linear structure is a pain. Tuples implicitly cated
>> when passed together an this make some things really hard. Allowing a
>> tuple to be a member of another tuple would put D template in the
>> same class as LISP.
>> 
>> Another things that might make things easier is some way to mark a
>> template as "evaluate to value and abandon". This would cause the
>> template to be processed but none of the symbols generated by it
>> would be kept, only the value. Of course, suitable restrictions would
>> apply.
>> 
> so it would be like writing normal D code inside of a template? Could
> we use phobos or do more metastring functions like find, strip, etc.
> need to be reinvented in D. Or can I take those functions and just put
> a wrapper around it? I think this is getting into the security issues
> again, but something like this:
> 

Errr. I was thinking of having this apply to the const folding stuff. Nothing 
that looks like runtime code would be allowed.

The point would be to reduce the overhead of evaluating stuff. After thinking 
about it, I'm not sure that this isn't already done for template that consist 
of only const declarations.

This would result in exactly one string being added to the compile time data 
set.

meta tempate rmwhite(char[] c)
{
  static if(c[0] != ' ')
    const rmwhite = c;
  else
    const rmwhite = rmwhite!(c[1..0]);
}





More information about the Digitalmars-d mailing list