How about 'pure' for constants?

Jarrett Billingsley kb3ctd2 at yahoo.com
Tue Dec 11 10:54:01 PST 2007


"Janice Caron" <caron800 at googlemail.com> wrote in message 
news:mailman.310.1197398288.2338.digitalmars-d at puremagic.com...
> On 12/11/07, Frits van Bommel <fvbommel at remwovexcapss.nl> wrote:
>> So opAdd & friends aren't CTFE'd? That seems like a silly omission, and
>> should be easy enough to fix.
>
> I figure "static" within struct declaration scope means "has no this
> pointer". Only at global scope does it mean CTFE.
>
> I guess "static" was a bad choice of keyword for CTFE!
>
> My personal choice of keyword for CTFE would be /none at all/. Why
> would you need one? Let the compiler decide! If the function is
> /called/ at compile time, then that should be enough to declare it as
> CTFE.

Where did you get this idea?  You don't need to declare a function in any 
special way, at global scope or in structs, to get it to work with CTFE.  If 
a function _can_ be called at compile time, it will be.  Otherwise, it will 
defer the call to runtime.  The same function can be evaluated at compile 
time and at runtime. 





More information about the Digitalmars-d mailing list