You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose we add dedicated modules that contain functions identical to existing standard library function except that they work on struct tuples and voptions rather than ref tuples and options. There are currently about a hundred such functions.
The best solution IMO would be new namespaces FSharp.Collections.Struct and FSharp.Control.Struct. This would give us the following new functions:
Doing this instead of adding new functions or submodules inside existing modules (eg List.Struct.tryFind or List.structTryFind) would allow different levels of buy-in:
Existing code would work as usual with ref types.
A user who wants to automatically use structs everywhere can write:
A user who wants to explicitly use the struct version of a function can write:
letx= Struct.List.tryFind f l
lete' = Struct.Event.pairwise e
Pros and Cons
The advantages of making this adjustment to F# are:
Allow reduced memory allocations when using standard library functions for users who explicitly care about it.
The disadvantages of making this adjustment to F# are:
A lot of new functions added to stdlib, which means more code to test, bigger FSharp.Core.dll, etc. Although a number of them should be able to share most of the existing implementation.
Extra information
Estimated cost (XS, S, M, L, XL, XXL): L
Related suggestions: (put links to related suggestions here)
Affidavit (please submit!)
Please tick this by placing a cross in the box:
This is not a question (e.g. like one you might ask on stackoverflow) and I have searched stackoverflow for discussions of this issue
This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.
Please tick all that apply:
This is not a breaking change to the F# language design
I or my company would be willing to help implement and/or test this
The text was updated successfully, but these errors were encountered:
Note that this overlaps with #739 and linked issue/PR.
Also, personally I'm not sure if I like the idea of identical names in a different namespace. At least IMHO it should be e.g. List.Struct.pick and not the other way around.
I actually like the idea that @cartermp had to allow this by using some type directed way, which would mean that each (core library) function that operates on, or returns, struct tuple or struct option, will automatically pick the right one based on type information. That way, this would keep the surface area maintainable.
Add struct-based versions of library functions
I propose we add dedicated modules that contain functions identical to existing standard library function except that they work on struct tuples and voptions rather than ref tuples and options. There are currently about a hundred such functions.
The best solution IMO would be new namespaces
FSharp.Collections.Struct
andFSharp.Control.Struct
. This would give us the following new functions:Doing this instead of adding new functions or submodules inside existing modules (eg
List.Struct.tryFind
orList.structTryFind
) would allow different levels of buy-in:Existing code would work as usual with ref types.
A user who wants to automatically use structs everywhere can write:
A user who wants to automatically use the struct version of specific modules can write:
A user who wants to explicitly use the struct version of a function can write:
Pros and Cons
The advantages of making this adjustment to F# are:
The disadvantages of making this adjustment to F# are:
Extra information
Estimated cost (XS, S, M, L, XL, XXL): L
Related suggestions: (put links to related suggestions here)
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
The text was updated successfully, but these errors were encountered: