<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<div id="divtagdefaultwrapper" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<p>Hi Marcel,</p>
<p><br>
</p>
<p>I'm a bit afraid of creating more subclasses of Collection or Dictionary for two reasons:</p>
<p><span style="font-size: 12pt;"><br>
</span></p>
<p><span style="font-size: 12pt;">1.</span><span style="font-size: 12pt;"> Different subclasses are incompatible. If you wanted a special dictionary that has weak keys and holds collections, you would need to create another subclass and duplicate some of the
 logic.</span></p>
<p><span style="font-size: 12pt;">2. Such a design change could introduce ambivalence and doubts about what subclass to choose, and if you choose the wrong class, you will need to do additional conversions. For example, should Collection >> #groupBy: return <span>CollectionsDictionary
 instances with your proposal? If there is any other legacy code that does not use CollectionsDictionary, you will need to check or fix its type to avoid DNUs when further logic might be added to <span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">CollectionsDictionary
 later</span>. Sometimes I have the feeling that the approach of creating too many collection/dictionary subclasses could violate the idea of polymorphy because they effectively remove genericity from their subclasses and refuse a lot of bequest (e.g., the
 math functions protocol from Collection).</span></span></p>
<p><span style="font-size: 12pt;"><span><br>
</span></span></p>
<p><span style="font-size: 12pt;"><span>That being said, I'm not completely against the idea, but these are some common concerns I have on collection subclassing in general. I would like to avoid ending up with a convoluted design such as .NET has, which contains
 next to the generic List<T>: StringList, StringCollection, StringDictionary, ListCollection, IntCollection, etc. ... :-)</span></span></p>
<p><span style="font-size: 12pt;"><span><br>
</span></span></p>
<p>Hypothetically, an alternative approach would be to add a new protocol to an existing superclass, for example 'list enumerating' on Dictionary, which would provide for compatibility with other data structures. For example, existing items could even be wrapped
 into a list when doing something like:</p>
<p><br>
</p>
</div>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<p>myDict at: <span>#fruits</span> put: #apple.</p>
</div>
<div style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<p>(myDict makeListAt: #fruits) addAll: #(banana cherry date).</p>
<p><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">(myDict mak</span><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">eListAt:
 #sweets) add: 'eclair; add: 'froyo'; add: 'gingerbread'.</span><br>
</p>
</div>
</blockquote>
<div style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<p><br>
</p>
<p>See Collection >> #associationsDo: for another example. What do you think about it? :-)</p>
<p><br>
</p>
<p>However, these are only my 2 cents without a clear opinion. Looking forward to your arguments! :-)</p>
<p><br>
</p>
<p>Best,</p>
<p>Christoph</p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr style="display:inline-block; width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Taeumel, Marcel<br>
<b>Gesendet:</b> Freitag, 26. März 2021 19:08 Uhr<br>
<b>An:</b> squeak-dev<br>
<b>Betreff:</b> Re: [squeak-dev] The Inbox: Collections-mt.932.mcz</font>
<div> </div>
</div>
<div>
<div id="__MailbirdStyleContent" dir="ltr" style="font-size:10pt; font-family:Arial; color:#000000; text-align:left">
Hi all!
<div><br>
</div>
<div>What do you think? Does it makes sense to pursue this idea of "dictionaries with collections as values" and enrich it with tests and documentation?</div>
<div><br>
</div>
<div>Best,</div>
<div>Marcel</div>
<div class="mb_sig"></div>
<blockquote class="history_container" type="cite" style="border-left-style:solid; border-width:1px; margin-top:20px; margin-left:0px; padding-left:10px">
<p style="color:#AAAAAA; margin-top:10px">Am 26.03.2021 19:05:09 schrieb commits@source.squeak.org <commits@source.squeak.org>:</p>
<div style="font-family:Arial,Helvetica,sans-serif">A new version of Collections was added to project The Inbox:<br>
http://source.squeak.org/inbox/Collections-mt.932.mcz<br>
<br>
==================== Summary ====================<br>
<br>
Name: Collections-mt.932<br>
Author: mt<br>
Time: 26 March 2021, 7:04:57.368373 pm<br>
UUID: b6c0c2c9-0a4f-684c-87a7-069813edd154<br>
Ancestors: Collections-dtl.931<br>
<br>
Sketch of a dictionary that has collections as values.<br>
<br>
dict := CollectionsDictionary new.<br>
(dict at: #fruits) addAll: #(apple apple peach).<br>
(dict at: #sweets) add: #nougat.<br>
dict removeKey: #sweets.<br>
dict explore.<br>
<br>
=============== Diff against Collections-dtl.931 ===============<br>
<br>
Item was added:<br>
+ Dictionary subclass: #CollectionsDictionary<br>
+ instanceVariableNames: 'collectionClass'<br>
+ classVariableNames: ''<br>
+ poolDictionaries: ''<br>
+ category: 'Collections-Unordered'!<br>
<br>
Item was added:<br>
+ ----- Method: CollectionsDictionary class>>defaultCollectionClass (in category 'defaults') -----<br>
+ defaultCollectionClass<br>
+ <br>
+ ^ OrderedCollection!<br>
<br>
Item was added:<br>
+ ----- Method: CollectionsDictionary class>>newOnBags (in category 'instance creation') -----<br>
+ newOnBags<br>
+ <br>
+ ^ self new<br>
+ setCollectionClass: Bag;<br>
+ yourself!<br>
<br>
Item was added:<br>
+ ----- Method: CollectionsDictionary class>>newOnOrderedCollections (in category 'instance creation') -----<br>
+ newOnOrderedCollections<br>
+ <br>
+ ^ self new<br>
+ setCollectionClass: OrderedCollection;<br>
+ yourself!<br>
<br>
Item was added:<br>
+ ----- Method: CollectionsDictionary class>>newOnSets (in category 'instance creation') -----<br>
+ newOnSets<br>
+ <br>
+ ^ self new<br>
+ setCollectionClass: Set;<br>
+ yourself!<br>
<br>
Item was added:<br>
+ ----- Method: CollectionsDictionary>>at: (in category 'accessing') -----<br>
+ at: key<br>
+ <br>
+ ^ self at: key ifAbsent: [super at: key put: collectionClass new]!<br>
<br>
Item was added:<br>
+ ----- Method: CollectionsDictionary>>at:put: (in category 'accessing') -----<br>
+ at: key put: value<br>
+ <br>
+ self shouldNotImplement.!<br>
<br>
Item was added:<br>
+ ----- Method: CollectionsDictionary>>collectionClass (in category 'accessing') -----<br>
+ collectionClass<br>
+ <br>
+ ^ collectionClass!<br>
<br>
Item was added:<br>
+ ----- Method: CollectionsDictionary>>initialize: (in category 'initialization') -----<br>
+ initialize: n<br>
+ <br>
+ super initialize: n.<br>
+ self setCollectionClass: self class defaultCollectionClass.!<br>
<br>
Item was added:<br>
+ ----- Method: CollectionsDictionary>>setCollectionClass: (in category 'initialization') -----<br>
+ setCollectionClass: aClass<br>
+ <br>
+ collectionClass := aClass.!<br>
<br>
<br>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</body>
</html>