From: "Ara.T.Howard" Date: 2004-06-26T00:03:05+09:00 Subject: Re: Is it considered Harmful? On Fri, 25 Jun 2004, Jim Weirich wrote: > > Scott Rubin said: >> I can't possibly imagine it being useful to do this except when the >> objects have very similar, if not identical, instance variables. > > The "standard" application for the self.class= method (aka become(class)) > is use it to do demand on load style proxies. Suppose you have a largish > object in external storage (database, file, whatever). You create a > small, efficient proxy item for the large object until you really need the > true data in the object. Then you load the object and let the proxy > "become" the newly loaded object. > > Without class=/become methods, > (a) the proxy remains and forwards all messages to the real object, or > (b) you replace every reference in the program to the proxy with > a reference to the real object. > > (a) is a small, but anoying constant cost, and (b) may be difficult, > depending on how wide spread the proxy was used. > > That's why class=/become would be attractive, despite its technical > difficulties and mildly worrisome semantices. > > -- > -- Jim Weirich jim@weirichhouse.org http://onestepback.org > ----------------------------------------------------------------- > "Beware of bugs in the above code; I have only proved it correct, > not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas) sounds like an RCR for Object#tie -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | A flower falls, even though we love it; | and a weed grows, even though we do not love it. | --Dogen ===============================================================================