dst = src rather than src dst

Janice Caron caron at serenityfirefly.com
Thu Sep 6 05:37:06 PDT 2007


-----Original Message-----
From: digitalmars-d-bounces at puremagic.com 
[mailto:digitalmars-d-bounces at puremagic.com] On Behalf Of Daniel Keep
Sent: 06 September 2007 04:44
To: digitalmars-d at puremagic.com
Subject: Re: dst = src rather than src dst

> But it's *not* assignment.

It's also not a declaration. If we're going to be strict, let us remember that

 int x;

reserves space at run-time for an actual value, to be later used in 
expressions, whereas

 alias int x;

reserves no such space. Saying "it isn't assignment" no more justifies 
declaration syntax, than saying "it isn't declaration" justifies assignment 
syntax.

The bottom line is, it's neither assignment nor declaration. It's its own 
thing. It has declaration syntax purely for historical reasons - because it was 
easier for C compilers to parse it that way. ("typedef int x" parses like 
"const int x" - that is, "typedef" is officially a "storage class").

In reality, it's a type definition - the keyword typedef is closer in meaning 
to struct, class or enum (or in C++, namespace) than anything else. In fact,

 typedef B A;

could reasonably be rewritten in D2.0+ as

 struct A
 {
  B b;
  alias b this;
 }

-- Not that I'm advocating such a strategy, of course. I'm just pointing out 
that a typedef is fundamentally different from a declaration, and so the 
justification for the dst src syntax on these grounds are minimal.






More information about the Digitalmars-d mailing list