Manifest constants (was const again)

Simen Kjaeraas simen.kjaras at gmail.com
Fri Dec 7 16:06:28 PST 2007


Bill Baxter wrote:
>>  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.

Thank you, I'm well aware of that. My point was typedef. Having typedef  
and alias (which do /similar/ things) have vastly different syntax would  
seem strange (and break existing code). Changing both to the 'op dst =  
src' syntax might have its advantages, though.

>> 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

I fully agree with that. Yet that is how things are at the moment, and at  
the very least we should strive to have a consistent syntax, so you don't  
define constants using 'alias a = 4' and types using 'alias src dst'.

Also, like some people like to point out (me often coding in notepad  
excludes me from that group), a good IDE might make it more obvious.



More information about the Digitalmars-d mailing list