Compile-time function execution: Difference between revisions

Content deleted Content added
Sam113101 (talk | contribs)
m Consts aren't computed at compile time.
Sam113101 (talk | contribs)
mNo edit summary
Line 41:
</source>
 
This example specifies a valid D function called "factorial" which would typically be evaluated at run time. The use of <code>constenum</code> tells the compiler that the initializer for the variables must be computed at compile time. Note that the arguments to the function must be able to be resolved at compile time as well.<ref>[http://d-programming-language.org/attribute.html#const D 2.0 language specification: Attributes]</ref>
 
CTFE can be used to populate data structures at compile-time in a simple way (D version 2):