Possible way to achieve lazy loading with const objects

Timon Gehr timon.gehr at gmx.ch
Mon Sep 26 04:01:45 PDT 2011


On 09/26/2011 02:46 AM, Walter Bright wrote:
> On 9/23/2011 9:11 PM, Jonathan M Davis wrote:
>> Okay. I'm not saying that we should necessarily implement this. I'm just
>> looking to air out an idea here and see if there are any technical
>> reasons why
>> it can't be done or is unreasonable.
>
> Andrei and I talked about this some time back. Where it ran aground was
> Andrei wanted a way to mark the object as 'dirty' so it would get
> reloaded. We couldn't find a way that didn't look like a mess.

lazyField=void ? :o)

>
> It also has problems if you try and add 'const' to it, because it is
> under the hood not const. Nor is it immutable or thread safe.

under the hood, a const can be either mutable or immutable. Calling a 
const member function does not at all preclude that the object is 
changed in D. immutable objects would have their lazy fields loaded 
eagerly. Thread safety: Every object in D is thread safe because 
unshared by default.


More information about the Digitalmars-d mailing list