Compile time function execution...

Walter Bright newshound at digitalmars.com
Thu Feb 15 12:55:54 PST 2007


Andrei Alexandrescu (See Website For Email) wrote:
> There is a need for a couple of ancillary features. Most importantly, a 
> constant must be distinguishable from a variable. Consider the example 
> of regex from our correspondence:
> 
> bool b = regexmatch(a, "\n$");
> 
> vs.
> 
> char[] pattern = argv[1];
> bool b = regexmatch(a, pattern);
> 
> You'd want to dispatch regexmatch differently: the first match should be 
> passed to compile-time code that at the end of the day yields:
> 
> bool b = (a[$-1] == '\n');
> 
> while the second should invoke the full-general dynamic pattern matching 
> algorithm since a dynamic pattern is used.

I think that can be done with an improvement to the existing compile 
time regex library.



More information about the Digitalmars-d mailing list