Explicit default constructor for structs
monarch_dodra
monarchdodra at gmail.com
Thu Apr 10 14:23:42 PDT 2014
On Thursday, 10 April 2014 at 19:28:16 UTC, Jacob Carlborg wrote:
> On 2014-04-10 17:21, Remo wrote:
>
>> Please do not forget about C++ porting problems that are
>> related to this.
>> The code from C++ should compile and work as expected or does
>> not
>> compile at all and give meaningful error message.
>> Right now it compiles but does not work at all.
>> This struct constructor problem is one of the ground why I
>> have stopped
>> porting code to D.
>> I hope there will be proper solution soon.
>
> How said anything about that? It has been said that one should
> be able to paste C code in a D file and have it compile with
> the same resulting semantics as in C or not compile at all. But
> never for C++.
Well, it's true that the idea is that you can copy paste C code
into D and it "just works", keeping the same semantics (provided
minor/trivial tweaks).
And nobody ever sold you could do the same thing with C++.
*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.
The "this(Arg arg = someDefault)" is a flagrant example of
something that should be rejected. Not only because it's stupid
to write in plain D, but also because it creates gratuitous
deviation from the behavior you'd get in C++. And that's actually
very bad (IMO).
More information about the Digitalmars-d
mailing list