no-arg constructor for structs (again)
Dmitry Olshansky
dmitry.olsh at gmail.com
Wed Sep 19 11:09:08 PDT 2012
On 19-Sep-12 15:52, monarch_dodra wrote:
> I realize *why* the "default" constructor had to go, but "no-arg" didn't
> have to go with it. I think it was an accident to let it go, and we
> should be trying to fix this.
I do not feel that there is a lot of reference-like types that take 0
arguments at construction. Any meaningful examples?
About checking for "was initialized" it is indeed painful, yet I believe
even C++ is in the same boat (empty shared_ptr?). Also I do suspect that
in the majority of cases these are just asserts since they aim to catch
logic errors in code.
Having a way to ensure initialization statically would be nice.
Currently only @disabling this() would achieve that but I suspect it's
somewhat bogus ATM.
In fact having @disable this() undermines the argument for "always have
T.init" strategy as generic code now have to deal with both cases.
> Could I get some feedback so I could make a formal and thorough
> enhancement request?
I'd rather see static opCall go and be replaced with no-arg constructor.
But this alone doesn't bring much benefit (if any).
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list