Possible way to achieve lazy loading with const objects

Marco Leise Marco.Leise at gmx.de
Thu Sep 29 00:13:19 PDT 2011


Am 26.09.2011, 18:12 Uhr, schrieb Jonathan M Davis <jmdavisProg at gmx.com>:

> On Monday, September 26, 2011 08:01:29 Steven Schveighoffer wrote:
>> For example, storing a reference to a mutex in an object, or a reference
>> to an owner object.  It's the difference between a "has a" relationship
>> and a "points to" relationship.
>>
>> Your lazy loading idea does not help at all for these.
>
> I believe that the two main complaints about the lack of logical const  
> which
> have been coming up in the newsgroup have been the inability to cache the
> return values of member functions and the inability to lazily load the  
> values of member variables.

I brought the issue with "points to" relationships up in another thread  
here - also about transitive const. I believe a proper object-oriented  
design should allow for pointers to other objects that have nothing in  
common with the host object. car.getVendor() for example should always  
return the mutable instance of the shop where that - possibly const car -  
was bought. Let's call it the "parent reference" issue for short :)
+1 to Steven's comment.


More information about the Digitalmars-d mailing list