Manifest constants (was const again)

James Dennett jdennett at acm.org
Sun Dec 23 13:51:42 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.

As does C++ with the advent of generalized "using" in C++0x.
Consistence with the past is one factor, but it's somtimes
given too much weight.

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

With more complex expressions, it's much less readable: the
item being defined is lost at the end of the declaration
(which is also a flaw with C's declaration syntax).

-- James



More information about the Digitalmars-d mailing list