alias A = B; syntax

Jonathan M Davis jmdavisProg at gmx.com
Mon Oct 15 22:27:36 PDT 2012


On Tuesday, October 16, 2012 07:17:54 Rob T wrote:
> 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.

The syntax is identical except for it being "alias" rather than "typedef" and 
their usage is near identical. C/C++ will allow you to typedef struct 
declarations instead of just their name

typedef struct {...} name;

which D won't let you do, and D will let you alias any symbol, whereas C/C++'s 
typedef only works on types. But since neither actually declares a new type, 
I'm unaware of any real difference between the two other than those I already 
mentioned. They're pretty much the same thing, so I don't know why you're 
saying that they're different.

Regardless, my point was that the syntax was the same and so that's where 
alias' syntax comes from.

- Jonathan M Davis


More information about the Digitalmars-d mailing list