Const sucks

Bill Baxter dnewsgroup at billbaxter.com
Mon Sep 10 13:40:51 PDT 2007


Nathan Reed wrote:
> Carlos Santander wrote:
>> Walter Bright escribió:
>>> o  So, we still need a method to declare a constant that will not 
>>> consume memory. We'll co-opt the future macro syntax for that:
>>>
>>>     macro x = 3;
>>>     macro s = "hello";
>>
>> Am I the only one who doesn't like this syntax? I guess it kinda makes 
>> sense, but I just don't like how it looks.
>>
> 
> Seems to me like this unnecessarily departs from the macro syntax 
> introduced at the conference:
> 
> macro foo(e) { e = 3; }
> 
> (On the other hand, in one of them the macro is for an expression while 
> in the other one it's a sequence of declarations/statements.  So maybe 
> it is reasonable to have the different syntax.)

It's not far off from things used in some functional programming 
languages, so it doesn't look to bad to me.  The word 'macro' typically 
implies a direct, maybe even textual, substitution.  It's also a lot 
like #define, just with an '=' there which I think is an improvement 
over #define.  '=' for the no-arg macros, '{ }' for the arg-ful macros. 
  Seems ok to me.

--bb



More information about the Digitalmars-d mailing list