Skip to content

Conversation

@forki
Copy link
Contributor

@forki forki commented May 11, 2015

@enricosada
Copy link
Contributor

@forki just return the sequence enumerator? why cast sequence of DictionaryEntry to IDictionary?

@forki
Copy link
Contributor Author

forki commented May 11, 2015

It needs to return IDictionaryEnumerator

@enricosada
Copy link
Contributor

i think the easier way is to create a class DictEnumerator, inherit from both the ArrayEnumerator (pass the mapped sequence as array) and implement IDictionaryEnumerator with members Key and Value to ArrayEnumerator.Current

nvm, not a good approach

the .net implementation is private HashtableEnumerator

@enricosada
Copy link
Contributor

@forki ok got it, you have a pull request forki#2

@forki forki force-pushed the dict branch 4 times, most recently from 05e662a to 945deac Compare May 11, 2015 14:09
@forki forki changed the title WIP: Try to implement System.Collections.IDictionary for dict Implement System.Collections.IDictionary for dict May 11, 2015
@@ -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
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had to exclude portable

Copy link
Contributor

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)

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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 😄

@forki
Copy link
Contributor Author

forki commented May 12, 2015

@dsyme so I finish at 50a2e40

@enricosada
Copy link
Contributor

i am pretty sure you need some unit tests

@forki
Copy link
Contributor Author

forki commented May 12, 2015

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:

i am pretty sure you need some unit tests


Reply to this email directly or view it on GitHub
#436 (comment)
.

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
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how?
image

Copy link
Contributor

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.

@latkin
Copy link
Contributor

latkin commented May 12, 2015

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 dict returns just IDictionary<_,_>, so the public contract is not changing. But capabilities are clearly changed, so it's effectively the same as surface area change.

@latkin
Copy link
Contributor

latkin commented Aug 4, 2015

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).

@latkin latkin closed this Aug 4, 2015
@dsyme
Copy link
Contributor

dsyme commented Aug 4, 2015

@forki would be good to have this in the pipe

@forki
Copy link
Contributor Author

forki commented Aug 4, 2015

I stopped because everything in F# repo got stopped...
On Aug 4, 2015 8:18 PM, "Don Syme" notifications@github.com wrote:

@forki https://github.com/forki would be good to have this in the pipe


Reply to this email directly or view it on GitHub
#436 (comment)
.

@forki
Copy link
Contributor Author

forki commented Aug 5, 2015

@latkin after closing this, what's your plan to get the feature in?

@dsyme
Copy link
Contributor

dsyme commented Aug 5, 2015

@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.

@latkin
Copy link
Contributor

latkin commented Aug 6, 2015

@forki @dsyme yes, please just re-open when the known feedback is addressed, or open a new one if you prefer. Sorry to be "bad cop" this week, just trying to tidy up the PR and issue list.

@forki
Copy link
Contributor Author

forki commented Aug 6, 2015

Actually it's very important to close things. Sorry for being a bit grumpy.
On Aug 6, 2015 10:48 PM, "Lincoln Atkinson" notifications@github.com
wrote:

@forki https://github.com/forki @dsyme https://github.com/dsyme yes,
please just re-open when the known feedback is addressed, or open a new one
if you prefer. Sorry to be "bad cop" this week, just trying to tidy up the
PR and issue list.


Reply to this email directly or view it on GitHub
#436 (comment)
.

@latkin latkin removed the V.Next label Aug 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants