in reply to Doubt about fly-weight objects.

Also, I'm very curious as to know wether someone has ever met any situation in which it has been useful or sensible to have part of the data "inside" the object and part of it stored in a package lexical: possibly by still using the object's blessed reference as in index into a hash, or by some other technique...

Class::DBI does exactly this. If enabled, there is an 'object index' which makes sure that there is only one instance of a given table row existing as an object at a time. This doesn't provided caching, but a means to make sure that you don't do something stupid since they aren't really multiple objects, just refs to the same row.

-- fast, working, cheap - pick two

Replies are listed 'Best First'.
Re^2: Doubt about fly-weight objects.
by blazar (Canon) on May 17, 2005 at 14:38 UTC
    Class::DBI does exactly this. If enabled, there is an 'object index' which makes sure that there is only one instance of a given table row existing as an object at a time. This doesn't provided caching, but a means to make sure that you don't do something stupid since they aren't really multiple objects, just refs to the same row.
    Interesting, especially since I do use Class::DBI, but mostly in a relatively naive way, since I've been exposed to it by more experienced (in Class::DBI itself, that is - and in DBses in general) coworkers.