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

Public [<Literal>]s as static members #746

Happypig375 opened this issue Jun 10, 2019 · 2 comments


None yet
3 participants
Copy link

commented Jun 10, 2019

Public [<Literal>]s as static members

I propose we allow public [<Literal>]s as static members.

The existing way of approaching this problem in F# is forcing to define the [<Literal>] in global level or in a module.


[<Struct>] type UserID = private UserID of int
    with [<Literal>] static member Maximum = 9999 //error currently, should allow

type ``THREE!!!!!!!!!``() = 
    let privateLiteral = 3 //currently allowed
    static member PublicLiteral = 3 //error currently, should allow

Pros and Cons

The advantages of making this adjustment to F# are

  1. one more parity with C#
  2. make literals more first class

The disadvantage of making this adjustment to F# is implementation effort required.

Extra information

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:

  • 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

This comment has been minimized.

Copy link

commented Jun 24, 2019

Agree. This would give better scoping.


This comment has been minimized.

Copy link

commented Jun 26, 2019

I also agree that this should be allowed, especially since you can already put them in modules.

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.