-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dictionary protocol and conversions between dictionary types #293
Comments
Yes! Now that we have The protocol should ultimately live in the Standard Library, but we could prototype it within this package. (Transitioning it into the stdlib later is going to be painful, though.) The tests include a couple of protocols to test that core Dictionary API is implemented consistently ( Design decisions:
Random notes:
|
Hey! Thanks for the thorough response.
What direct difficulties do you expect? I do see the general challenge of adding a protocol to such a fundamental type in the standard library. And perhaps there not being direct other types that would profit from this protocol in the stdlib.
I would definitely say DictionaryProtocol would refine Sequence. Since we're not really interested in the way the elements are stored at the time of using a protocol, one of the big uses would be to be able to loop over the elements of the Dictionary I would think. Are there any drawbacks to refining Sequence? Just to double check by refining you mean the following?
I would think so. I'm not too familiar with the other newer implementations but this does seem an interesting addition to the protocol. If we had a SetProtocol we could restrict our keys associated type to that too perhaps?
This is interesting, it might be worthwhile keeping them seperate for a first pass and find out if there's clear benefits? They're not directly obvious to me. But in a way we would be mirroring Collection and MutableCollection which does make sense to me in terms of structuring. I'd say we there should be a clear reason to split them otherwise we're just adding complexity perhaps.
No direct ideas/opinions on this, but that is a good point to keep in mind.
Yeah especially if we would have something like OrderedDictionary's elements view in the protocol that should be easy to have a default implementation for perhaps?
Hm not sure about this I'd have to take another look! What are your thoughts for something similar for Set? |
Sorry taking a little longer than expected since I'm a little swamped with work :) I have a basic thing that might make sense to share soon so we have something tangible to discuss and improve on!
whereas
What are your thoughts on this @lorentey? I'd argue that the Edit: |
Hey @lorentey ! Just wanted to check if you have any thoughts on the current PR I submitted. Would love to move this forward :) |
Put some more thought into this and took a look at SortedDictionary. Unfortunately none of the initialisers there match with the Dictionary and OrderedDictionary ones. Making it hard to get an initialiser defined in the protocol itself. That in turn would make incorporating a mapping between dictionary types in the protocol hard to do too. Have not looked at the TreeDictionary type yet since unifying a protocol over SortedDictionary, OrderedDictionary and plain Dictionary is already proving quite hard.
Which so we can't have a general initialiser in the protocol. Any thoughts on this? Would love to hear your thoughts so I can move further on the implementation of this! |
Hey everyone! Two ideas for Dictionary types:
Let me know your thoughts! Would this be useful to you? Potential problems you envision or reasons to not do this in general? Would love to hear it, thanks!
These might also be interesting uses for the different types of Set that exist
The text was updated successfully, but these errors were encountered: