Explicit default constructor for structs
Jonathan M Davis
jmdavisProg at gmx.com
Fri Apr 11 06:03:56 PDT 2014
On Friday, April 11, 2014 22:38:28 Daniel Murphy wrote:
> "monarch_dodra" wrote in message
> news:rftskgfoeuvyeuvrusei at forum.dlang.org...
>
> > *BUT*, if you happen to copy paste C++ code, and it *does* compile, then
> > it is pretty much expected to keep the same resulting semantics, yes.
>
> These expectations will lead to disappointment.
One of the goals of D was to make it so that when _C_ code was compiled as D
code, it either wouldn't compile or would have identical semantics, and I
believe that that is still true save for a very short list of exceptions (the
only ones that come to mind are that the calling conventions wouldn't be the
same and that static arrays are value types in D whereas they're reference
types in C).
However, that's not at all true for C++. You're probably more likely to be
able to port Java code directly and have it have the same semantics than C++
code. A shining example of that is the semantics for variables of class types.
In C++, if they're not declared as pointers, then they're value types, whereas
they're always reference types in D.
Part of the whole point of D is to have better semantics than C++, so it's
certainly not going to try and keep the same semantics as C++. For the most
part, we haven't gratuitously changed the semantics, but there are a lot of
places where we gained something by changing them, so we did.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list