-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add proposal for partial events and constructors #9059
Conversation
|
||
A defining partial constructor declaration: | ||
- Cannot have a constructor initializer (`: this()` or `: base()`; [§15.11.2][ctor-init]). | ||
- Does not perform any variable initializers ([§15.11.3][ctor-var-init]). |
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 find it a little confusing to actually specify this, it makes me wonder if we give the same precaution about extern
constructors.
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.
You are right we probably don't need to specify this here, because the spec of variable initializers talks about "instance constructors" which in case of partial ones are composed of a defining and an implementing declaration - so the whole "constructor" will perform the initializers, it doesn't make sense to talk about the partial declarations themselves performing (or not performing) the initializers.
But since you brought this up, to me it seems like the spec has a hole for extern
constructors. Right now the spec wording sounds like variable initializers would be executed by extern
constructors but they won't be.
Also one can have a class like:
class C
{
int X = 5;
extern C();
}
but the initializer is completely ignored by the compiler (it's not emitted anywhere).
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.
It is odd. If you wish, you could open an issue on csharpstandard.
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.
Opened dotnet/csharpstandard#1253
|
||
The attributes of the resulting event or constructor are the combined attributes of the partial declarations. | ||
The attributes of each of the resulting event's accessor | ||
are the combined attributes of the corresponding partial declaration accessors. |
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.
The attributes of the resulting event or constructor are the combined attributes of the partial declarations. | ||
The attributes of each of the resulting event's accessor | ||
are the combined attributes of the corresponding partial declaration accessors. | ||
The attributes of each of the resulting constructor's parameter |
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.
Perhaps "The attributes of each resulting constructor parameter ..." or "The attributes of each of the resulting constructor's parameters ..." (plural).
Only the defining declaration of a partial member participates in lookup | ||
and is considered at use sites and for emitting the metadata. | ||
(Except for documentation comments as detailed [below](#documentation-comments).) | ||
The implementing declaration signature is used when nullable-analyzing the associated bodies. |
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.
Otherwise, it is a *defining declaration*. | ||
|
||
A partial constructor declaration is said to be a *defining declaration* | ||
when it has the semicolon body and it lacks the `extern` modifier. |
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.
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 assume you are referring to "the semicolon body", not "the extern
modifier" here? I chose "the" because there is only one semicolon body ever (the semicolon), but perhaps that's not the right way to think about it.
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.
Yes, "when it has a semicolon body".
### Attributes | ||
|
||
The attributes of the resulting event or constructor are the combined attributes of the partial declarations. | ||
The attributes of each of the resulting event's accessor |
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.
Perhaps "The attributes of each resulting event accessor ..." or "The attributes of each of the resulting event's accessors ..." (plural).
No description provided.