A little of Partial Compilation

Don nospam at nospam.com.au
Wed Aug 20 00:27:20 PDT 2008


bearophile wrote:
> Jarrett Billingsley:
>> Yes, it means you have to do it manually, but still, it's nice to be able
>> to offer an optimized version of a function for certain values for parameters.
> 
> Making this "conversion" automatic can be useful because as time passes the D compiler may gain more capabilities to run things at compile time (like I think trigonometric functions, recently, in D 2.x), this means that more values can become run time constants (even ones that the programmer doesn't know can be run time constants), this is an opportunity to optimize some functions more like I have said.

The original proposal was mine.
But I think automatic conversion
(1) would really kill compilation times; and
(2) is hardly ever going to be desirable. Execution speed hardly ever 
matters. The time when it is really a killer feature is for something 
like a regexp, where you can give a compile-time error if the regexp is 
invalid, and precompile it if it is OK.

Note that even if all parameters to a function are known at compile 
time, doesn't mean it's sensible to run it at compile time. (Example: 
calculating pi to fifty billion decimal places). The programmer needs to 
annotate it somehow to tell the compiler that is suitable for compile time.



More information about the Digitalmars-d mailing list