On Thursday, 8 September 2016 at 10:36:22 UTC, Dicebot wrote:
As a workaround I sincerely believe explicit 'create' (with
forged mangling if needed) is better. It provides exactly the
same functionality without tricking the developet into
expecting more by confusion of the syntax similarity.
If I was to enforce a programming standard with static opCall().
The code for instantiating the Mutex example would look like:
Mutex foo = Mutex();
Later on down the track, behind the scenes when default
constructors work for C++ types I remove the static opCall()
implementation and replace it with default constructors. Right
now, Mutex() without static opCall() just gives me the .init.
With the static opCall(), I can construct it. With a default
constructor?
I suppose that'd depend on future decisions that haven't been
made yet. In C++ Mutex() is meant to invoke the zero initialiser.
It's effectively the opposite in D when using static opCall().
Which one would be the correct way to default construct a class?
We'll find out I suppose.
Either way, assuming the default constructor will be called
regardless of if it's foo = Mutex; or foo = Mutex();, using
static opCall() will cut down on future maintenance work.
We're going to disagree on this one, basically. I'm designing
this system for people who don't want to have to remember to call
fancy create functions.