Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Underscores in numeric literals after prefix and before suffix #718

Open
chadunit opened this Issue Jan 27, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@chadunit
Copy link

chadunit commented Jan 27, 2019

Underscores in numeric literals after prefix and before suffix

I propose we allow underscores in numeric literals after the base prefix and before the type suffix.

Currently, leading/trailing underscores in numeric literals are not allowed after the prefix or before the suffix. This lessens readability because the leading and trailing groups blend into the additional characters and lose their visual "shape".

0b1111_1111uy // valid
0b_1111_1111_uy // not valid (proposal to allow)

Is there a rationale for disallowing these underscores? According to RFC FS-0005, the rules seem to be modeled after a pre-existing ruleset from Java. There don't seem to be arguments for or against this specific restriction so it's not clear if it was actively favored or if it just came along for the ride. (Thus I don't believe this necessarily counts as "already been decided" per the affidavit below.)

Also note that some other languages have chosen to be less restrictive:

0b_1111_1111 // C# 7.2 - leading underscore valid
0b_1111_1111_u8 // Rust - leading and trailing underscore valid

(C# reference, Rust reference)

Pros and Cons

The advantages of making this adjustment to F# are: better readability

The disadvantages of making this adjustment to F# are: none that I know of

Extra information

Estimated cost (XS, S, M, L, XL, XXL): S

Related suggestions: F# RFC FS-0005 - Underscore Literals

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.