-
Notifications
You must be signed in to change notification settings - Fork 93
[Version 9.0] Feature support for records #1458
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
base: draft-v9
Are you sure you want to change the base?
Conversation
Add support for record classes Add files via upload Add support for record classes Add support for record classes fix markup fix markdown formatting fix markdown formatting fix link another missed link
|
|
||
| An awaiter’s implementation of the interface methods `INotifyCompletion.OnCompleted` and `ICriticalNotifyCompletion.UnsafeOnCompleted` should cause the delegate `r` to be invoked at most once. Otherwise, the behavior of the enclosing async function is undefined. | ||
|
|
||
| ## §with-expressions With expressions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add "with" as a new row to the table in the (earlier) section "Operator precedence and associativity." And as we have historically organized the sections in this clause in descending precedence order, we might need to move this new section up or down, accordingly.
| class_tag | ||
| : 'class' | ||
| | 'record' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: In V9, record means record class but we can't say that explicitly. In V10, this is permitted and we'll replace these 2 rules with 'record'? 'class'.
|
|
||
| A *class_declaration* is a *type_declaration* ([§14.7](namespaces.md#147-type-declarations)) that declares a new class. | ||
|
|
||
| ```ANTLR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heads up grammarians! As you will see below, I have a generous syntax for a class in which not all combinations are permitted, and those combinations are described in text as constraints. (For example, a record class can have a delimited_parameter_list while a non-record class cannot. And for a record class, class_modifier shall not be static.) Yes, we could try to break this up into separate rules for record classes and non-record classes to eliminate some (but maybe not all) of those constraints. However, there will be tweaks to this grammar in future versions; specifically:
- V10 allows
record classas well asrecord. - V10 supports
record struct. - V12 allows a primary constructor (which uses delimited_parameter_list) on non-record classes and structs.
which means that extra work done now to make the grammar rules more complete likely will be (at least partially) undone in future revs.
|
|
||
| The method performs the following tasks: | ||
|
|
||
| 1. Calls the method `System.Runtime.CompilerServices.RuntimeHelpers.EnsureSufficientExecutionStack()` if that method is present and the record class has printable members. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to expose this type in the spec?
Tweaks I made when comparing this PR with what I researched 2+ years ago.
It is quite possible that some members will think that some (maybe a lot) of the text is "implementation detail," which should be discarded and (presumably) replaced with some minimal wording.
All commits from #983 have been squashed and added to this PR.
This PR / feature makes numerous changes to the grammar. We still need corresponding updates to the test and validation suite.
The following notes are carried over for additional work needed:
A. I put the new subclause "With expression" prior to "Arithmetic operators", which once the V8 features "Indices and Ranges" and "Pattern matching" have been merged, should immediately follow "Range operator" and "Switch expression." Make sure these are all in the correct place. 12.4.2 Operator precedence and associativity will also need to be revised accordingly.
B. New subclause §rec-class-prtmem Printing members mentions a method
System.Runtime.CompilerServices.RuntimeHelpers.EnsureSufficientExecutionStack(). It's quite possible that this is an implementation-specific detail, in which case, we'll need to find words to make it abstract, and possibly update the Portability annex accordingly.