-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Hexadecimal, octal and binary custom numeric literals
I propose we allow first-class support of colors.
module NumericLiteralR = ... // Implementation unchanged from before
let x : Color = 0xff00ff00R // Hexadecimal color literal!The existing way of approaching this problem in F# is either through functions taking non-decimal strings or converting from integers.
Pros and Cons
The advantages of making this adjustment to F# are
- Consistency - custom numeric literals should have the same support with built-in ones
- Ease of use - enabling BigIntegers from their binary form
- Support for more DSLs - e.g. Colors
The disadvantage of making this adjustment to F# is an implementation in the F# compiler converting hexadecimal, octal and binary strings to decimal strings to call FromString would probably be required.
Extra information
Estimated cost (XS, S, M, L, XL, XXL): M
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
- 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
rmunn