another idea for compile time functions

janderson askme at me.com
Fri Feb 9 00:31:29 PST 2007


Andrei Alexandrescu (See Website For Email) wrote:
> janderson wrote:
> Me too. Once compile-time interpretation (and mutation) makes it in, I 
> think there's no fear of efficiency loss anymore. Speed will be 
> comparable to that of any interpreted code, and there are entire 
> communities that don't have a problem with that.
> 
> The question is, what is the subset of D that can be interpreted? I'm 
> thinking:
> 
> * Basic data types (they will be stored as a dynamically-typed variant 
> anyway), except pointers to functions and delegates.
> 
> * Arrays and hashes
> 
> * Basic expressions (except 'is', 'delete' et al.)
> 
> * if, for, foreach, while, do, switch, continue, break, return
> 
> I'm constructing this list thinking what it takes to write basic data 
> manipulation functions. What did I forget?
> 
> 
> Andrei

Looking at this from a template perspective.  If we don't have 
classes/structs.  How much would the template system need to be changed 
to work like this?  I mean, as I said before "static if" -> "if" and the 
other operations and compile-time data types (arrays/AA's).  Its very 
close to what we want.  Not quite as reusable, but the template syntax 
would be improved.

One issue I have with templates is they cause compilation to slow down 
and bloat the executable code.  Maybe a template with no arguments 
should be compiled as a normal function without inlining.  That would 
solve most of those problems.

-Joel



More information about the Digitalmars-d mailing list