Compile time function execution...

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Thu Feb 15 13:52:43 PST 2007


Bill Baxter wrote:
> Walter Bright wrote:
>> Walter Bright wrote:
>>> This should obsolete using templates to compute values at compile time.
>>
>> For contrast, compare with the C++ proposal:
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1972.pdf
> 
> It's kinda long and boring, but it looks like the key differences are
> 
> 1) The need to tag compile-time functions with a new keyword, 
> "constexpr", though they seem to sell this as an advantage.  "a 
> programmer can state that a function is intended to be used in a 
> constant expression and the compiler can diagnose mistakes." -- page 9.
> 
> 2) The restriction that a constexpr function can only contain "return" 
> followed by exactly one expression.  No loops for you!  And I hope you 
> like quadruply nested b?x:y expressions!

3) The C++ feature is applicable to user-defined types.

Andrei



More information about the Digitalmars-d mailing list