Hello,

I have read various things about struct constructors, specifically 0 argument constructors, and using opCall and @disable this(); which no longer seems to work.

What I am after I think is the behavior of C++'s structs on the stack, namely for some or all of these uses at a given time:


1. Allocation on the stack
2. Value type semantics
3. RAII (combined with (1) often)

The scope keyword on classes has been deprecated, it seems because it was hard to detect returning destroyed scope references, otherwise that might have done the job.


Is it the case that a struct should now be used with a factory method? Does this also mean that the struct destructor must be made to work when .init is called instead of the factory method?

This idiom is inconsistent with struct constructors that do have one or more arguments, and I think that this question is likely to arise time immemorial from others who are not expecting this particular inconstancy.

Would it not make sense to ban constructors on structs entirely -- or find another solution that clears this up?





Reply via email to