Possible way to achieve lazy loading with const objects
Regan Heath
regan at netmail.co.nz
Mon Sep 26 06:44:31 PDT 2011
On Mon, 26 Sep 2011 13:01:29 +0100, Steven Schveighoffer
<schveiguy at yahoo.com> wrote:
> On Sat, 24 Sep 2011 00:11:52 -0400, Jonathan M Davis
>> 6. If the S being constructed is shared or immutable and __varProp is
>> not
>> called in the constructor, then __varProp is called immediately after
>> the
>> constructor (or at the end of the constructor if that works better for
>> the
>> compiler).
>
> Why? What if the calculation is very expensive, and you never access
> var?
>
> Besides, we can already pro-actively initialize data in an immutable
> constructor, what is the benefit here?
I think this is to avoid threading issues, like double checked locking
problems etc.
--
Using Opera's revolutionary email client: http://www.opera.com/mail/
More information about the Digitalmars-d
mailing list