-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Updating tuples spec with grammar #11271
Changes from 10 commits
863badc
a1ae8b3
c031c63
0a5f0b2
f9da878
0095906
bd82e7e
7398568
3a483f5
34ae162
7d380d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,3 +230,65 @@ M1((1, ()=>(2, 3))); // the first overload is used due to "exact match" | |
|
||
``` | ||
|
||
Language grammar changes | ||
--------------------- | ||
This is based on the [ANTLR grammar](https://raw.githubusercontent.com/ljw1004/csharpspec/gh-pages/csharp.g4) from Lucian. | ||
|
||
For tuple type declarations: | ||
|
||
```ANTLR | ||
struct_type | ||
: type_name | ||
| simple_type | ||
| nullable_type | ||
| tuple_type // new | ||
; | ||
|
||
tuple_type | ||
: '(' tuple_type_element_list ')' | ||
; | ||
|
||
tuple_type_element_list | ||
: tuple_type_element ',' tuple_type_element | ||
| tuple_type_element_list ',' tuple_type_element | ||
; | ||
|
||
tuple_type_element | ||
: type_parameter identifier? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Thanks |
||
; | ||
``` | ||
|
||
For tuple literals: | ||
|
||
```ANTLR | ||
literal | ||
: boolean_literal | ||
| integer_literal | ||
| real_literal | ||
| character_literal | ||
| string_literal | ||
| null_literal | ||
| tuple_literal // new | ||
; | ||
|
||
tuple_literal | ||
: '(' tuple_literal_element_list ')' | ||
; | ||
|
||
tuple_literal_element_list | ||
: tuple_literal_element ',' tuple_literal_element | ||
| tuple_literal_element_list ',' tuple_literal_element | ||
; | ||
|
||
tuple_literal_element | ||
: ( identifier ':' )? literal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. I'll fix. |
||
; | ||
``` | ||
|
||
A tuple literal cannot be used as default value for an optional parameter. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is non-normative (it is implied by rules elsewhere), so perhaps precede by "Because it is not a constant expression, " #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that was the reason (not a constant). I'll add a note. |
||
|
||
Open issues: | ||
----------- | ||
|
||
- Provide more details on semantics of tuple type declarations, both static (Type rules, constraints, all-or-none names, can't be used on right-hand-side of a 'is', ...) and dynamic (what does it do at runtime?). | ||
- Provide more details on semantics of tuple literals, both static (new kind of conversion from expression, new kind of conversion from type, all-or-none, scrambled names, underlying types, underlying names, listing the members of this type, what it means to access, ) and dynamic (what happens when you do this conversion?). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add "exactly matching expression" to this list. I suggest the checkbox syntax to list them
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
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.
Ultimately I think you want to integrate the related sections of the spec. That is, for each context integrate the syntax, semantics, and dynamic semantics, rather than having the prose above and syntax below without relating them to each other.
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.
I agree.