define should be the keyword for manifest constants
Steven Schveighoffer
schveiguy at yahoo.com
Thu Dec 13 13:42:35 PST 2007
"Russell Lewis" wrote
>I thought about suggesting this, but what turned me off to it was this
>declaration:
>
> define int x = some_compile_time_func();
>
> A C/C++ programmer will probably think of this as a #define-style
> substitution, which means that he will expect the function to run every
> time that he uses the constant. However, what we are trying to declare is
> a manifest constant. It seemed like it would introduce confusion.
>
> Just my $.02,
> Russ
Too bad, so sad. If you want something that acts exactly like C, use C. D
already uses lots of C keywords differently than C does, that was my
original point.
And Bill Baxter's point is right on. If the function is compile time, no
need to execute it every time it's used because the result will already be
evaluated by the compiler.
-Steve
More information about the Digitalmars-d
mailing list