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

Open
Happypig375 opened this issue Jun 10, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@Happypig375
Copy link
Contributor

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.

e.g.

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

type ``THREE!!!!!!!!!``() = 
    [<Literal>]
    let privateLiteral = 3 //currently allowed
    [<Literal>]
    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
@charlesroddie

This comment has been minimized.

Copy link

commented Jun 24, 2019

Agree. This would give better scoping.

@cartermp

This comment has been minimized.

Copy link
Member

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.