[squeak-dev] The Inbox: Collections-mt.932.mcz

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Sat Mar 27 19:00:30 UTC 2021


Hi Marcel,


do I understand correctly that your point is to reach polymorphy with other types of dictionaries? Well, that changes things, of course. :-)

(Then again, which client can expect a regular dictionary not to answer KeyNotFound for arbitrary items that have not been added before? )

I think the use case of mapping values to collections is not being represented in a sufficient way in the current Collections API, thus I find your proposal very interesting. For reference, .NET has IGrouping`2<https://docs.microsoft.com/de-de/dotnet/api/system.linq.igrouping-2?view=net-5.0> which appears as a similar concept to me. I don't want to block your proposal in any way (not that I would be in that position at all :D), I'm just curious about our plans on subclassing Dictionary in general.
Just for interest, do you maybe have some other concrete use cases for a CollectionsDictionary in Squeak? :-)

Best,
Christoph
________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Tony Garnock-Jones <tonyg at leastfixedpoint.com>
Gesendet: Freitag, 26. März 2021 20:26:31
An: The general-purpose Squeak developers list; Taeumel, Marcel
Betreff: Re: [squeak-dev] The Inbox: Collections-mt.932.mcz

What about something like:

   collection: aClass at: key do: aBlock
     | coll result |
     coll := self at: key ifAbsentPut: [aClass new].
     result := aBlock value: coll.
     coll ifEmpty: [self removeKey: key].
     ^ result

... perhaps with `ensure:` to do the removal?

Then:

   myDictOfSets collection: Set at: #key1 do: [:s | s add: 123].


On 3/26/21 8:17 PM, Marcel Taeumel wrote:
> ...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20210327/e9501fed/attachment-0001.html>


More information about the Squeak-dev mailing list