[Newbies] Re: Recap: How to empty a collection
nicolas cellier
ncellier at ifrance.com
Wed Feb 20 01:17:44 UTC 2008
Blake a écrit :
> On Tue, 19 Feb 2008 15:59:57 -0800, nicolas cellier
> <ncellier at ifrance.com> wrote:
>
>> However, there are plenty of ordinary things that would have the same
>> result:
>>
>> | key1 key2 dic |
>> key1 := 'abc' copy.
>> key2 := 'abd' copy.
>> dic := Dictionary new.
>> dic at: key1 put: 1.
>> dic at: key2 put: 2.
>> key1 at: 1 put: $z.
>> {dic includesKey: key1.
>> dic keys includes: key1.}
>>
>> So i propose newbies do not use #at:put: considering the danger about
>> Dictionary not finding their keys...
>
> This seems pretty bad to me, too, but it seems more designed to break a
> known weakness than to actually accomplish something. You know, like
> empty a collection.<s>
>
Yes, the example is dumb, but that's the kind of thing that happens in
real code (just split contructing/changing keys/accessing in three
different methods).
No use to forbid become: for this reason, there are better reasons (it's
sloooow), become: usage was sponsored once upon a time when it was fast,
providing both efficient and generic solutions.
> But I'd probably argue that the above should work, and that it's a
> design flaw that it doesn't.
>
Yes, but it is very hard to make it work efficiently.
So that's a limitation we must be aware of.
>> Anyway, why do you think all code is accessible in Smalltalk?
>> In the spirit, nothing is to be hidden from newbies eyes.
>> Yes I know, maybe some code should
>
> There's a positive fetish about this. I'm all for everything being
> accessible. But everything being equally accessible all the time is not
> pragmatic.
More information about the Beginners
mailing list