From: Brian Marick Date: 2001-10-26T12:23:30+09:00 Subject: [ruby-talk:23392] Re: class Foo does not call Class.new? At 04:32 PM 10/25/01, you wrote: >No. But in 1.7.1, I defined something I call "allocation framework", >which is > > * basically, no "new" overriding (that allows your Class#new trick > work in many cases). > > * instance allocation is done by "allocation" method of the class, > for example, Array#allocation for arrays. > > * there's a few exceptions remain, for example Class does not call > "allocation". I'm afraid I don't understand. Will I be able to do metaclass tricks? For example, my chapter has a series of examples that build on a class IceCream that sometimes creates a Celery instance. The first one starts like this: class IceCream def IceCream.new(starting_licks) Celery.new end end and I build from there. Then I show how a change to a single method (Class#new) lets me have each class count its instances (as shown in my original note). That will tie back into the IceCream example. Will I be able to do equivalent things using the new mechanism? That's the kind of thing that makes Ruby share the specialness of Smalltalk and Lisp: you can accomplish so much with combinations of simple rules. ("A class is an object, and new is a method, so let's see what we can do by overriding it.") I'll be sad if I can't do those things, and it will take away one of the two big triumphant climaxes from the book. -- Brian Marick, marick@testing.com www.testing.com - Software testing services and resources www.testingcraft.com - Where software testers exchange techniques www.visibleworkings.com - Adequate understanding of system internals