[squeak-dev] Re: Circular definitions of size and do:
eliot.miranda at gmail.com
Mon Oct 3 17:05:41 UTC 2011
On Sun, Oct 2, 2011 at 8:51 PM, Rodney Polkinghorne <
rpolkinghorne at groupwise.swin.edu.au> wrote:
> >> Is this considered a bug, or a learning experience for new players?
> By "this", I meant the consequence of my error (expected "Error: Foo
> needs a method for size", got a hung image), and the effort required
> to find its cause. I agree with Eliot's suggestion, that
> SequenceableCollection>>size should raise an error.
> > You should not instantiate an abstract class.
> To follow that advice, I'd need a way to find out which classes were
> abstract, and when I'd implemented enough methods to stop them being
> abstract. That seems to be a black art in Smalltalk.
> There are two ways I could have written this. One is to define a
> subclass of Collection, and use the built-in collect:, inject:into:
> and so on. The other is to subclass Object, and define the iterators
> that I was going to use. Which approach is more common?
The former is the one that makes sense. Why reinvent the wheel? The
Collection hierarchy is designed to be both used and reused (subclassed).
Copy-paste merely wastes space, makes the system more complex, and harder
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev