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

Update spec for record value equality #3396

Merged
merged 2 commits into from
May 24, 2020
Merged

Update spec for record value equality #3396

merged 2 commits into from
May 24, 2020

Conversation

agocke
Copy link
Member

@agocke agocke commented Apr 25, 2020

No description provided.

@agocke agocke marked this pull request as ready for review April 27, 2020 23:13
`T Equals(T)` is specified to perform value equality, comparing the property with same name as
each primary constructor parameter to the corresponding property of the other type.
`T Equals(T)` is specified to perform value equality such that `Equals` is
true if and only if all the instance fields of the receiver type are equal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equal [](start = 69, length = 5)

I don't know what equals means. How is this possible, given that the fields of the base class might not be accessible?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the exact same language the spec uses for anonymous types, so if it's underspecified, that's an existing problem :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, anonymous types don't have a base class. In any case, some other existing text being underspecified isn't an excuse. I think you should just say object.Equals(x, y) (and mention as an aside that the implied boxing may be elided)


In reply to: 418282509 [](ancestors = 418282509)

@gafter
Copy link
Member

gafter commented Apr 30, 2020

class_declaration

This is ambiguous with the existing production, e.g. for class A { }. It is intended to replace it? If so the base clause is missing.


Refers to: proposals/records-wip.md:9 in 04e750a. [](commit_id = 04e750a, deletion_comment = False)

@gafter
Copy link
Member

gafter commented Apr 30, 2020

: attributes? class_modifiers? 'partial'? 'class' identifier type_parameter_list?

Did you intend to augment the modifiers to include data?


Refers to: proposals/records-wip.md:10 in 04e750a. [](commit_id = 04e750a, deletion_comment = False)

@gafter
Copy link
Member

gafter commented Apr 30, 2020

The attributes non-terminal will also permit a new contextual attribute, data.

attribute or modifier? If it is contextual, what, precisely, is the context? Can it be placed between two other attributes? Can you please show the modified attributes production, if it is modified?


Refers to: proposals/records-wip.md:30 in 04e750a. [](commit_id = 04e750a, deletion_comment = False)

@agocke
Copy link
Member Author

agocke commented Apr 30, 2020

Syntactic issues shouldn't be relevant to this PR, so I'll deal with them later

@@ -67,8 +67,10 @@ Record types produce synthesized implementations for the following methods:
* `object.Equals(object)` override, unless it is sealed or user provided
* `T Equals(T)` method, where `T` is the current type

`T Equals(T)` is specified to perform value equality, comparing the property with same name as
each primary constructor parameter to the corresponding property of the other type.
`T Equals(T)` is specified to perform value equality such that `Equals` is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specified [](start = 17, length = 9)

Where can we find this specification you speak of? ;)

@agocke agocke merged commit 300226c into master May 24, 2020
@agocke agocke deleted the records-value-equals branch May 24, 2020 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants