alias A = B; syntax
Rob T
rob at ucora.com
Mon Oct 15 22:17:54 PDT 2012
On Tuesday, 16 October 2012 at 04:32:29 UTC, Jonathan M Davis
wrote:
> On Tuesday, October 16, 2012 06:08:27 Marco Leise wrote:
>> Just recently I wondered how the current syntax could possibly
>> have come into existence. >)
>
> It's the same as C's typedef syntax.
>
> - Jonathn M Davis
Alias is not the same thing as C's typedef, but I understand it
originally evolved out that way from C's version of typedef.
I agree that the current syntax does at first seem inconsistent
with most other things in the language, and I found myself typing
it in reverse with the = when I first tried using it, eg
alias Int = int;
On the other hand, I could argue that variable declarations are
also inconsistent in the same way, eg
int i; // the "declare" keyword is implied
instead of
declare i = int;
So
alias int Int;
is indeed rather consistent with how type declarations are
currently done. Unfortunately, inconsistencies create needless
waste, but fixing something like that may be not worth the gain
once it becomes deeply rooted in the language.
It may not be to late to change the syntax for alias definitions,
but the type declarations will no doubt remain as they are, and
the rest of it that is the reverse of type declarations will also
likely remain as they are.
--rt
More information about the Digitalmars-d
mailing list