Do we have better collections design library?
Hi. I just found that there is no WeakIdentityValueDictionary. But we have WeakValueDictionary, WeakKeyDictionary, WeakIdentityKeyDictionary. And to implement missing class I need to copy overrides from IdentityDictionary. And weak key dictionaries are implemented same way by duplicating code. And generally identity collections are not much different from equal collections but they still duplicate a lot of code with little difference: #hash or #identityHash, #= or #==. So I am wondering do we have alternative implementation with proper design? There are wishes to replace streams by XSteams. What about collections? Best regards, Denis
Let us start with streams :) On Fri, Jun 2, 2017 at 11:20 AM, Denis Kudriashov <dionisiydk@gmail.com> wrote:
Hi.
I just found that there is no WeakIdentityValueDictionary. But we have WeakValueDictionary, WeakKeyDictionary, WeakIdentityKeyDictionary.
And to implement missing class I need to copy overrides from IdentityDictionary. And weak key dictionaries are implemented same way by duplicating code.
And generally identity collections are not much different from equal collections but they still duplicate a lot of code with little difference: #hash or #identityHash, #= or #==.
So I am wondering do we have alternative implementation with proper design? There are wishes to replace streams by XSteams. What about collections?
Best regards, Denis
Hi Denis, On Fri, Jun 2, 2017 at 2:20 AM, Denis Kudriashov <dionisiydk@gmail.com> wrote:
Hi.
I just found that there is no WeakIdentityValueDictionary. But we have WeakValueDictionary, WeakKeyDictionary, WeakIdentityKeyDictionary.
And to implement missing class I need to copy overrides from IdentityDictionary. And weak key dictionaries are implemented same way by duplicating code.
And generally identity collections are not much different from equal collections but they still duplicate a lot of code with little difference: #hash or #identityHash, #= or #==.
So I am wondering do we have alternative implementation with proper design?
The StrongTalk team reimplemented their Collections hierarchy to have much better modularity because their VM did the necessary inlining to create the efficient versions on the fly. This is what Scorch/Sista supports. Perhaps we should wait until it arrives, perhaps not, but certainly what you propose is a good idea whose time has almost come.
There are wishes to replace streams by XSteams. What about collections?
Best regards, Denis
-- _,,,^..^,,,_ best, Eliot
Denis Kudriashov wrote
Hi.
I just found that there is no WeakIdentityValueDictionary. But we have WeakValueDictionary, WeakKeyDictionary, WeakIdentityKeyDictionary.
And to implement missing class I need to copy overrides from IdentityDictionary. And weak key dictionaries are implemented same way by duplicating code.
And generally identity collections are not much different from equal collections but they still duplicate a lot of code with little difference: #hash or #identityHash, #= or #==.
So I am wondering do we have alternative implementation with proper design? There are wishes to replace streams by XSteams. What about collections?
Best regards, Denis
I think design deficiencies of Pharo collections can be addressed with traits. Now Pharo has classes that mix: - public interface of some type of collection - implementation of numerous operations on collections (e.g. #collect:) - implementation of collection's interface (e.g. #do:) Also different interfaces (iteration, mutation) are mixed together as well. For example, Collection could be replaced by TIterable (iteration and other methods from Collection that don't require mutation) and TCollection (TIterable + adding and removing). TIterable then can also be used for things like iterators/views/slices. Similarly, SequenceableCollection -> TSequenceable (uses TIterable) and TSequenceableCollection (uses TCollection + TSequenceable). Dictionary -> TMap (uses TIterable) and TDictionary (uses TCollection + TMap). Perhaps also separate traits for immutable collections, that use iteration traits and know how to make modified versions of themselves and how to construct instance from stream. For hashed collections, separate traits could be made for equality- and identity-based collections. Perhaps they can even be made right now, without reorganizing whole collections hierarchy - just by moving corresponding methods into them. -- View this message in context: http://forum.world.st/Do-we-have-better-collections-design-library-tp4948936... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
2017-06-04 19:32 GMT+02:00 webwarrior <reg@webwarrior.ws>:
I think design deficiencies of Pharo collections can be addressed with traits.
There was some work around it: https://hal.inria.fr/inria-00511902/file/main.pdf. (funny that it it was named Bloc )
Denis Kudriashov wrote
2017-06-04 19:32 GMT+02:00 webwarrior <
reg@
>:
I think design deficiencies of Pharo collections can be addressed with traits.
There was some work around it: https://hal.inria.fr/inria-00511902/file/main.pdf. (funny that it it was named Bloc )
Why has it been abandoned? -- View this message in context: http://forum.world.st/Do-we-have-better-collections-design-library-tp4948936... Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
Lack of manpower :) We should have put a good engineer on it for 3-4 months. More important stuff to do. Now I have the code. And we are about to release a better trait implementation with state. So if people want to play and redesign a collection library I'm really supporting the idea. Stef On Sun, Jun 4, 2017 at 10:10 PM, webwarrior <reg@webwarrior.ws> wrote:
Denis Kudriashov wrote
2017-06-04 19:32 GMT+02:00 webwarrior <
reg@
>:
I think design deficiencies of Pharo collections can be addressed with traits.
There was some work around it: https://hal.inria.fr/inria-00511902/file/main.pdf. (funny that it it was named Bloc )
Why has it been abandoned?
-- View this message in context: http://forum.world.st/Do-we- have-better-collections-design-library-tp4948936p4949274.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
;) this is nice to write papers just to remember and document our experiments. On Sun, Jun 4, 2017 at 10:13 PM, Denis Kudriashov <dionisiydk@gmail.com> wrote:
2017-06-04 19:32 GMT+02:00 webwarrior <reg@webwarrior.ws>:
I think design deficiencies of Pharo collections can be addressed with traits.
There was some work around it: https://hal.inria.fr/ inria-00511902/file/main.pdf. (funny that it it was named Bloc )
participants (4)
-
Denis Kudriashov -
Eliot Miranda -
Stephane Ducasse -
webwarrior