-
Notifications
You must be signed in to change notification settings - Fork 847
Implement System.Collections.IDictionary for dict #436
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
Conversation
|
@forki just return the sequence enumerator? why cast sequence of DictionaryEntry to IDictionary? |
|
It needs to return IDictionaryEnumerator |
|
nvm, not a good approach the .net implementation is private HashtableEnumerator |
add IDictionaryEnumerator
05e662a to
945deac
Compare
| @@ -70,6 +81,78 @@ module ExtraTopLevelOperators = | |||
| let key = RuntimeHelpers.StructBox(k) | |||
| if d.ContainsKey(key) then (r <- d.[key]; true) else false | |||
| member s.Remove(k : 'Key) = (raise (NotSupportedException(SR.GetString(SR.thisValueCannotBeMutated))) : bool) | |||
| #if FX_NO_READONLY_COLLECTIONS | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FX_ATLEAST_45 is not enough? IReadOnlyDictionary msdn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had to exclude portable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FSHARP_CORE_PORTABLE? because there are really a lot of defines already.
i mean FX_ATLEAST_45 && (!FSHARP_CORE_PORTABLE)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if FX_ATLEAST_45 && not FSHARP_CORE_PORTABLE
but why not explicitly exlude with ne flag. seems like a common pattern here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are already lot of defines, and is going to be messier with netcore.
i dont think the best long term is one define per class, instead we should simplify the codebase and build permutations
Another factor is: if you undefine FX_NO_READONLY_COLLECTIONS, that's not enogh to compile if the class doesn't exists in the framework. Is not a pure feature flag (like WSDL define )
but that's my idea /cc @dsyme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use feature-based defines (FX_NO_READONLY_COLLECTIONS) rather than platform defines (FX_ATLEAST_45, FSHARP_CORE_PORTABLE). Granularity of "features" is up to you - merge related ones where possible, split where necessary,
thanks
Don
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx for reply @dsyme nice to know 😄
|
i am pretty sure you need some unit tests |
|
yep. but I didn't find tests for the original dict function 2015-05-12 10:36 GMT+02:00 Enrico Sada notifications@github.com:
|
| member s.ContainsKey(k) = d.ContainsKey(RuntimeHelpers.StructBox(k)) | ||
| member s.TryGetValue(k,r) = | ||
| let key = RuntimeHelpers.StructBox(k) | ||
| if d.ContainsKey(key) then (r <- d.[key]; true) else false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use d.TryGetValue here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type DictWrapper<'k,'v>(d : Dictionary<_,_>) =
member __.TryGetValue(a : 'k, [<System.Runtime.InteropServices.Out>]b : 'v byref) =
d.TryGetValue(a, &b)Might as well fix above, too.
|
Looks good so far, just a few comments on properly filling out the various interfaces. Definitely needs tests. I'd say this should be post-F# 4.0. Can we release it without changing the FSharp.Core version number? Technically the signature of |
|
This has been idle for over 2 months, closing out. If remaining feedback can be addressed and tests added we'd be happy to including this in any upcoming release (doesn't change surface area so should be ok to add in an update). |
|
@forki would be good to have this in the pipe |
|
I stopped because everything in F# repo got stopped...
|
|
@latkin after closing this, what's your plan to get the feature in? |
|
@forki I think you can just reopen with the testing added. Closing was just spring cleaning, some work of mine got closed and I reopened with some progress. |
|
Actually it's very important to close things. Sorry for being a bit grumpy.
|

I tried to implement http://fslang.uservoice.com/forums/245727-f-language/suggestions/7845018-make-the-result-of-the-dict-function-implement-idi but got stuck at:
I assume this is only for vNext + 1