Fri, 02 Oct 2009 16:56:48 -0400, bearophile thusly wrote:

> A good purpose for compile-time functions is to pre-generate constant
> data structures, avoiding to waste time generating them at compile time.
> But currently creating fixed-sized arrays at compile time while possible
> is tricky (it's easy for me to write code that doesn't compile. So I'd
> like D2 to become more flexible here). Constant associative arrays
> defined at compile time may use perfect hashing functions that can be
> used at run time. And generating structures with pointers is not
> possible at compile time (possible usage for such structure: a trie that
> stores a constant dictionary, avoiding both build and load time, even if
> loading the precomputed chunk of memory of the array at run time takes a
> short time). At compile time indexes can be used instead of pointers,
> for example allocating the trie nodes into a compile time array and then
> using indexes to link nodes together.

You have probably already noticed that there is always a tradeoff to be 
made. Either you get smaller binaries and faster compilation times or 
larger binaries and (perhaps) more efficient runtime performance. Note 
that if the data structures are small, generating them takes very little 
time on modern 32/64-bit hardware. OTOH if you have tens of megabytes of 
binary data in your .exe, hard drives are a serious bottleneck.

Reply via email to