<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 2/6/24 5:21 PM, Juan Vuletich wrote:<br>
</div>
<blockquote type="cite" cite="mid:65C25C99.6090805@cuis.st">Let me
also elaborate a bit on the rationale.
<br>
<br>
In Smalltalk-80 (and every other Smalltalk system since then), the
docs will say that #new: will answer a collection of the requested
size. But it is not like that for Set, Dictionary,
OrderedCollection and a few others, that give a completely
different semantics to this message. It is no _that_ bad when the
message is sent to an explicit class, although you need to be
aware of this.
<br>
</blockquote>
<u><b>NO!</b></u><br>
Let me quote from my snarfed copy of the Bluebook/ Page 139<br>
"The messages <tt>new</tt> and <tt>new:</tt> can be used to create
instances of particular kinds of collections."<br>
<br>
That's all that's said about <tt>#new:</tt>.<br>
<br>
If you look at the Smalltalk80 comment for <tt>OrderedCollection>>#new:</tt>
here it is:<br>
<img src="cid:part1.2F68609F.2C705F6A@klix.ch" alt=""><br>
<tt>Set>>#new:</tt> looks like this:<br>
<img src="cid:part2.51020020.434A285C@klix.ch" alt=""><br>
<br>
<br>
That's the comment for <tt>IdentityDictionary>>#new:</tt><br>
<img src="cid:part3.CB711EC7.4E7F15CE@klix.ch" alt=""><br>
Nothing is said about the semantics of <tt>#new:</tt>, instead the
comments mostly<br>
deal with implementation details.<br>
<blockquote type="cite" cite="mid:65C25C99.6090805@cuis.st">
<br>
The real problem is when someone does `someCollection species new:
aNumber`. It gets really tricky to find out what is going to
happen.
<br>
</blockquote>
This wasn't the case with Smalltalk-80, it had 8 implementors of <tt>#new:</tt>.<br>
<blockquote type="cite" cite="mid:65C25C99.6090805@cuis.st">
<br>
This is a prime example of what I call "False Polymorphism". It
looks like a polymorphic message, but it is not. It is (at least)
two sets of senders/implementors, completely separated. This means
obscure, misleading code. It makes me sick. I fix every instance
of this I see. It rarely happens in the base Smalltalk-80 classes,
but it is still wrong.
<br>
</blockquote>
The main issue is, that you are deeply convinced<br>
that the postulate that<br>
<tt><someClass> new: <someSmallPositiveInteger></tt>
answers an object of size<br>
<tt>someSmallPositiveInteger </tt>is true. This never was the case.<br>
Your point about false polymorphism isn't a semantic one,<br>
it's a purely pragmatic one. If I had to maintain Cuis, I would<br>
love to have some simpler semantics for <tt>#new:</tt>, but also<br>
I support backwards compatibility over several versions.<br>
<br>
For Haver I will implement the following:<br>
<br>
<tt>#new:</tt> will keep its – admittedly – confusing semantics.<br>
<tt>#sizeOf:</tt> will create a SequenceableCollection of the right
size<br>
and signal an error for Sets and their sub classes.<br>
If I need it, I will implement <tt>#forceSizeOf:</tt> for sets<br>
and dictionaries that will create such a beast<br>
with n arbitrary objects or arbitrary keys mapped to <tt>nil</tt>.<br>
<br>
When I have the proper infrastructure for deprecation in place,<br>
I will rethink adopting your changes to the semantics of <tt>#new:</tt>.<br>
<br>
I will do this, despite the fact that I am the only user of Haver,
that I <br>
know about.<br>
<br>
<br>
Best Regards,<br>
<br>
Gerald<br>
<br>
<br>
<br>
</body>
</html>