Manifest constants (was const again)

Bill Baxter dnewsgroup at billbaxter.com
Fri Dec 7 14:14:22 PST 2007


Simen Kjaeraas wrote:
> Oskar Linde wrote:
>> Janice Caron wrote:
>>>> alias str = "str";
>>>  I'm uncomfortable with having
>>>      alias dest = source;
>>>  in one circumstance, but
>>>      alias source dest;
>>>  in others. I would find that confusing.
>>
>> Then just make the two forms equivalent and maybe depreciate the 
>> second one with time.
>>
>> alias pi = 3.14;
>> alias toString = to!(string);
>>
>> Why would this be a problem?
>>
> 
> Because it breaks with the C/C++ heritage, methinks.

I hate to point out the obvious, but there is no "alias" in C or C++.
Ok, yes there's typedef in C, but if you go and completely change the 
keyword used, I think you are justified in changing the syntax.

> Anyways, is there a reason why we can't use 'alias 3.14 pi;'?

Things like
    alias 3.14 + ctfe_func("two") / other_constant pi;

make that much harder to read than

    alias pi = 3.14 + ctfe_func("two") / other_constant;

But the same is true for the current type aliases.  You can see it a lot 
in templates.  There its not uncommon to see things like

   alias some long thing that eventually figures out a type Foo;

--bb



More information about the Digitalmars-d mailing list