But then the source object may not be mutable. I am not a compiler expert, but could a special case be made in D compiler for the cases where the source struct instance is mutable and is made available to ease such lazy initialization?


I am suggesting a DIP here.

Could the postblit take two arguments and make the source object available for possible mutation? We could have two variants of the postblit and the one with two arguments (source and destination *this* pointers) could be applied only to the cases where the source struct instance is mutable. And the normal postblit (in the form we have now) could apply to the cases where the source struct instance is immutable. As I said, I am not a compiler expert and I do not know if what I am saying makes sense.

Regards
- Ritu

Reply via email to