From: Jim Weirich Date: 2004-06-25T22:32:57+09:00 Subject: Re: Is it considered Harmful? 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)