Compile time function execution...

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Thu Feb 15 20:45:04 PST 2007


Derek Parnell wrote:
> On Thu, 15 Feb 2007 10:23:43 -0800, Walter Bright wrote:
> 
>> ... is now in DMD 1.006. For example:
> On Thu, 15 Feb 2007 10:23:43 -0800, Walter Bright wrote:
> 
>> ... is now in DMD 1.006.
> 
> I guess its time I came clean and admitted that in spite of this being a
> huge technological advancement in the language, I can't see why I'd ever be
> needing it.
> 
> I mean, when it comes down to it, it's just a fancy way of getting the
> compiler to calculate/generate literals that can be done by myself anyway,
> no? These literals are values that can be determined prior to writing one's
> code, right?

This is by far the least interesting application of this stuff. I don't 
even count it when I think of the feature. "Oh, yeah, I could compile 
square root at compile time. How quaint."

> This is not a troll posting, so can anyone enlighten me on how this ability
> will reduce the cost of maintaining code? I am very open to being educated.

Great. The main uses of the feature will be in creating libraries that 
work with and _on_ your code (in the most literal sense). I've given the 
regexp example a few posts back: using the straight regular expression 
syntax, you direct a library into generating optimal code for each and 
every of your regular expressions, without ever having to do anything 
about it.

There's been also much discussion about the applications of code 
generation, and you can be sure they will be simplified by one order of 
magnitude by dual functions.


Andrei



More information about the Digitalmars-d mailing list