const again

Ary Borenszweig ary at esperanto.org.ar
Thu Dec 6 17:48:42 PST 2007


Walter Bright wrote:
> Ary Borenszweig wrote:
>> Why not
>>
>> macro x = 3;
>> ?
> 
> It's been suggested several times. It doesn't make much aesthetic sense 
> to do things like:
> 
>     macro int x = 3;

Well, macros like that would almost always refer to primitive types: 
ints, bools, strings, etc. So the type will be ommited most of the time. 
I can't come up with an example for a constant (like #define) that needs 
to declare it's type (in fact, #define doesn't declare a type). If it's 
an enum, you would say

macro foo = SomeEnum.value;

If it's a constant field in a type, it's the same way. If you want to 
have some constant initialized in a "static this", than it can't be done 
with the macro syntax.



More information about the Digitalmars-d mailing list