-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Decimal, nativeint and unativeint literals
I propose we allow decimal, nativeint and unativeint literals.
The existing way of approaching this problem in F# is (none).
C# 9 now has native-sized integers.
Together with decimal constants, C# 9 can now define three types of literals that F# cannot. To interface with them, we must be able to interpret and define decimal, nativeint and unativeint literals.
let [<Literal>] Decimal = 3m
let [<Literal>] NativeInt = 3n
let [<Literal>] UNativeInt = 3un
match 3n with NativeInt -> true | _ -> false // truePros and Cons
The advantages of making this adjustment to F# are
- Consistency between numeric types - all other numeric types can be defined as literals. Why not these three?
- Increased interoperability with C#
- More code reuse - more chances to refactor constant patterns in `match's into literals that can be changed easily
The disadvantages of making this adjustment to F# are none that I can think of.
Extra information
Estimated cost (XS, S, M, L, XL, XXL): S
Related suggestions:
#562
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
- I have searched both open and closed suggestions on this site and believe this is not a duplicate
- 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
charlesroddie, Szer, abelbraaksma, Entomy, jwosty and 7 more