<div dir="auto">I would say not the class but the receiver is the only one with the full context, as illustrated by Text>>grownTo: (and other examples in my code)</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 7, 2024 at 01:57 Andres Valloud via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st">cuis-dev@lists.cuis.st</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">Be careful with that "false polymorphism" argument. Going down that <br>
route means you can ignore the receiver's class when you see a selector <br>
because a selector can only have one meaning. In a sense, it promotes <br>
selectors to operators.<br>
<br>
It should be pretty clear that collections like Array and Set should <br>
behave differently. Why is that being ignored?<br>
<br>
Consider this alternate interpretation. The root cause of this problem <br>
seems to be that some code has the expectation that<br>
<br>
species new: n<br>
<br>
can have exactly one meaning. The sender is ignoring the receiver <br>
class. Only the receiver class has that context. So the receiver class <br>
should be given the task of creating the new instance instead --- this <br>
is why arithmetic has double dispatching, for example.<br>
<br>
Andres.<br>
<br>
On 2/6/24 8:21 AM, Juan Vuletich via Cuis-dev wrote:<br>
> Let me also elaborate a bit on the rationale.<br>
> <br>
> In Smalltalk-80 (and every other Smalltalk system since then), the docs <br>
> will say that #new: will answer a collection of the requested size. But <br>
> it is not like that for Set, Dictionary, OrderedCollection and a few <br>
> others, that give a completely different semantics to this message. It <br>
> is no _that_ bad when the message is sent to an explicit class, although <br>
> you need to be aware of this.<br>
> <br>
> The real problem is when someone does `someCollection species new: <br>
> aNumber`. It gets really tricky to find out what is going to happen.<br>
> <br>
> This is a prime example of what I call "False Polymorphism". It looks <br>
> like a polymorphic message, but it is not. It is (at least) two sets of <br>
> senders/implementors, completely separated. This means obscure, <br>
> misleading code. It makes me sick. I fix every instance of this I see. <br>
> It rarely happens in the base Smalltalk-80 classes, but it is still wrong.<br>
> <br>
> Thanks,<br>
> <br>
-- <br>
Cuis-dev mailing list<br>
<a href="mailto:Cuis-dev@lists.cuis.st" target="_blank">Cuis-dev@lists.cuis.st</a><br>
<a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
</blockquote></div></div>