[squeak-dev] Re: Circular definitions of size and do:

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Mon Oct 3 17:28:37 UTC 2011


2011/10/3 Eliot Miranda <eliot.miranda at gmail.com>:
>
>
> 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
> to maintain.

That's true, that's why I think that my first proposition of having
both #size and #do: abstract was a bit lighter (no duplication
required).

Nicolas

>>
>> Rodney
>>
>
>
>
> --
> best,
> Eliot
>
>
>
>



More information about the Squeak-dev mailing list