On Monday, 30 December 2013 at 16:10:35 UTC, Andrei Alexandrescu wrote:
On 12/30/13 3:34 AM, Ritu wrote:

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.

Did you take a look at http://wiki.dlang.org/DIP49 and http://wiki.dlang.org/DIP53?

Andrei

I have done that now. These DIPs though related, do not make the original object available for modification. But since DIP49 allows qualification of postblit, I believe what I am asking for becomes very much possible as an extension. We just need to provide another overloaded "mutable" postblit that would provide access to the "original" as well as "copied" struct instances.

I believe this will go a long way in fixing the behavior of some containers like the appender too. In general it will make "lazy initialization" much more usable in D.

Regards
- Ritu

Reply via email to