Forcing compile time evaluation of pure functions

bearophile bearophileHUGS at lycos.com
Thu Jul 14 19:47:00 PDT 2011


scarrow:

> I'd really like to figure out how to have Hash("foo") be static and Hash(variable) be dynamic.

In GCC there is a way to (sometimes) do it, see the __builtin_constant_p here:
http://www.delorie.com/gnu/docs/gcc/gcc_81.html

Time ago I have asked for something similar in D too, because I think it allows to implement a poor's man manual "partial compilation" using templates. Maybe it's worth asking about this in the main D newsgroup. But before asking, it's better to have few use cases examples :-)

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list