define should be the keyword for manifest constants

Vladimir Panteleev thecybershadow at gmail.com
Thu Dec 13 14:13:59 PST 2007


On Thu, 13 Dec 2007 22:43:41 +0200, Bill Baxter <dnewsgroup at billbaxter.com> wrote:

> 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.
>
> That may be their first guess as to what it does, but it doesn't seem
> like it would be difficult to relieve oneself of that misconception.
>
> And in any case, the only time the above would work is if
> some_compile_time_function() really is a compile time function.  So it
> doesn't really matter if the user wants to think of it as evaluating
> every time it's used or just once.  That's the whole point of
> compile_time / pure functions.  No side effects and context doesn't matter.

In that case, what's wrong with "alias"? It sounds good, it has the same problem (misconception of substitution), but isn't a new keyword.

-- 
Best regards,
 Vladimir                          mailto:thecybershadow at gmail.com



More information about the Digitalmars-d mailing list