compile-time variables?

Bruno Medeiros brunodomedeiros+spam at com.gmail
Sat May 26 06:02:00 PDT 2007


Pragma wrote:
> Fraser wrote:
>> In particular, I want a mixin template that mixes in a  unique numeric 
>> ID as part of a function every time it's used in a mixin. 
> 
> This is possible, but it will take some mildly ugly code to 
> accomplish*.  The major hurdle to overcome is that templates are 
> effectively stateless.  This is because every template invocation is 
> dependent upon its arguments and global constants for evaluation, and is 
> unable to change anything but its own definition.  The result is that 
> there's no compile-time analog for simple stuff like this:
> 
[...]
> 
> (* welcome to meta-programming)
> 

It's more specific than that. Like "welcome to D meta-programming". 
Meta-programming in other languages, like macros in Lisp, are done as 
normal Lisp code and thus also have state (as I believe you know already).
In D that's not the case, and I find it interesting, and even kinda of 
funny and ironic, that D meta-programming is a *completly* pure 
functional programming world :P . Funny and ironic because the first 
thing that poped to mind when I first "entered" D meta-programming, was 
the Scheme pure functional programs we (me and my fellow colleagues) did 
some years ago in my college's first-year, SICP-based college course. :)

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list