-
Notifications
You must be signed in to change notification settings - Fork 144
add [fs-1141] Allow access modifiers to auto properties getters and setters #764
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
124 changes: 124 additions & 0 deletions
124
RFCs/FS-1141-Allow-access-modifiers-to-auto-properties-getters-and-setters.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| # F# RFC FS-1141 - Allow access modifiers to auto properties getters and setters | ||
|
|
||
| The design suggestion [Allow access modifies to auto properties getters and setters](https://github.com/fsharp/fslang-suggestions/issues/430) has been marked "approved in principle". | ||
|
|
||
| This RFC covers the detailed proposal for this suggestion. | ||
|
|
||
| - [x] [Suggestion](https://github.com/fsharp/fslang-suggestions/issues/430) | ||
| - [x] Approved in principle | ||
| - [x] [Implementation](https://github.com/dotnet/fsharp/pull/16687) | ||
| - [ ] Design Review Meeting(s) with @dsyme and others invitees | ||
| <!-- - [Discussion](https://github.com/fsharp/fslang-design/discussions/FILL-ME-IN) --> | ||
|
|
||
| # Summary | ||
|
|
||
| Allow access modifiers to auto properties getters and setters. | ||
|
|
||
| # Motivation | ||
|
|
||
| To simplify the syntax of defining a private-settable-read-only properties. | ||
|
|
||
| # Detailed design | ||
|
|
||
| Allowing placing access modifiers before getter and setter of auto properties when no access modifier specified before the property name. | ||
|
|
||
| Syntax: | ||
|
|
||
| ```fsharp | ||
| // Automatically implemented properties. | ||
| [ attributes ] | ||
| [ static ] member val [accessibility-modifier] PropertyName = initialization-expression [ with [accessibility-modifier] get, [accessibility-modifier] set ] | ||
| ``` | ||
|
|
||
| Example: | ||
|
|
||
| ```fsharp | ||
| type A() = | ||
| member val internal B = 0 with get, set | ||
| // allow | ||
| member val B2 = 0 with public get, private set | ||
| // not allowed | ||
| member val internal B3 = 0 with public get, private set | ||
|
|
||
| ``` | ||
|
|
||
| # Drawbacks | ||
|
|
||
| > A more way to do same thing. | ||
|
|
||
| # Alternatives | ||
|
|
||
| What other designs have been considered? What is the impact of not doing this? | ||
|
|
||
| > Write an explicit property with getter and setter. | ||
|
|
||
| ```fsharp | ||
| type A() = | ||
| [<DefaultValue>] | ||
| val mutable private _B: int | ||
| member this.B with public get () = this._B and private set value = this._B <- value | ||
| ``` | ||
|
|
||
| # Compatibility | ||
|
|
||
| Please address all necessary compatibility questions: | ||
|
|
||
| * Is this a breaking change? | ||
|
|
||
| > No | ||
|
|
||
| * What happens when previous versions of the F# compiler encounter this design addition as source code? | ||
|
|
||
| > Build error | ||
|
|
||
| * What happens when previous versions of the F# compiler encounter this design addition in compiled binaries? | ||
|
|
||
| > Unchanged, as explicit property works. | ||
|
|
||
| * If this is a change or extension to FSharp.Core, what happens when previous versions of the F# compiler encounter this construct? | ||
|
|
||
| # Pragmatics | ||
|
|
||
| ## Diagnostics | ||
|
|
||
| Please list the reasonable expectations for diagnostics for misuse of this feature. | ||
|
|
||
| ## Tooling | ||
|
|
||
| Please list the reasonable expectations for tooling for this feature, including any of these: | ||
|
|
||
| * Debugging | ||
| * Breakpoints/stepping | ||
| * Expression evaluator | ||
| * Data displays for locals and hover tips | ||
| * Auto-complete | ||
| * Tooltips | ||
| * Navigation and Go To Definition | ||
| * Colorization | ||
| * Brace/parenthesis matching | ||
|
|
||
| ## Performance | ||
|
|
||
| Please list any notable concerns for impact on the performance of compilation and/or generated code | ||
|
|
||
| * For existing code | ||
| * For the new features | ||
|
|
||
| ## Scaling | ||
|
|
||
| Please list the dimensions that describe the inputs for this new feature, e.g. "number of widgets" etc. For each, estimate a reasonable upper bound for the expected size in human-written code and machine-generated code that the compiler will accept. | ||
|
|
||
| For example | ||
|
|
||
| * Expected maximum number of widgets in reasonable hand-written code: 100 | ||
| * Expected reasonable upper bound for number of widgets accepted: 500 | ||
|
|
||
| Testing should particularly check that compilation is linear (or log-linear or similar) along these dimensions. If quadratic or worse this should ideally be noted in the RFC. | ||
|
|
||
| ## Culture-aware formatting/parsing | ||
|
|
||
| Does the proposed RFC interact with culture-aware formatting and parsing of numbers, dates and currencies? For example, if the RFC includes plaintext outputs, are these outputs specified to be culture-invariant or current-culture. | ||
|
|
||
| # Unresolved questions | ||
|
|
||
| What parts of the design are still TBD? | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.