Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
I propose we move slicing/indexing methods for array/string to type extensions. The current way slicing is wired up results in weird behavior overloading GetSlice on arrays, where you can define an overload only if it has a different amount of arguments from what we already have in Core.
The existing way of approaching this problem in F# is:
The spec is misleading here, as from the code snipped above it is evident there is no GetSlice extension on array/string. Instead in the typechecker the syntax is analyzed and the correct concrete slice implementation is directly picked, based on how many arguments are in the slice.
Pros and Cons
The advantages of making this adjustment to F# are:
The disadvantages of making this adjustment to F# are ...
Estimated cost (XS, S, M, L, XL, XXL): S
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:
@dsyme thoughts? In order to handle slicing properly for 3D and 4D arrays, we'd have to use type extensions. So that would create a world where there are type extensions for 3D and 4D arrays, which can be shadowed, but not for 1D and 2D arrays. This would also bring the implementation in line with what the spec says.
As I mentioned in the implementation PR, quotations of array indexing may have an issue here, e.g.
So in theory this is a breaking change, and I wouldn't be at all surprised if there were quotation processing libraries that looked for
I didn't go too deep into the implementation, but since the old slicing methods in prim-types are public API, we would keep them around. This would address any compatibility concerns. The change is we'll get rid of the code in typechecker that hardcodes the calls to these slicing methods. The slicing methods will still be used, but wired up through type extensions instead. Android 版 Outlook<https://aka.ms/ghei36> の入手…
________________________________ From: Don Syme <firstname.lastname@example.org> Sent: Tuesday, October 22, 2019 8:59:59 AM To: fsharp/fslang-suggestions <email@example.com> Cc: Nelson Wu <firstname.lastname@example.org>; Author <email@example.com> Subject: Re: [fsharp/fslang-suggestions] Move array/string slicing/indexing methods to type extensions (#796) (I presume a fix for that could be inserted in the stage of the compiler that makes quotations) ― You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub<#796?email_source=notifications&email_token=AEAF2FVO7OD4ZMUUZQW5T5LQP4PP7A5CNFSM4JCMNUM2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEB6IXUI#issuecomment-545033169>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AEAF2FRBVCMONNCWNVRQSE3QP4PP7ANCNFSM4JCMNUMQ>.