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

Clarify extension member resolution #4116

Merged
merged 3 commits into from
Oct 2, 2024
Merged

Conversation

eernstg
Copy link
Member

@eernstg eernstg commented Oct 1, 2024

See #4113 for some background information.

This PR changes the rule about extension applicability such that it is clarified that static members are irrelevant, it is only required that the static type of the receiver does not have an instance member with the same basename as the selector which is potentially an extension member invocation.

There is no implementation effort associated with this specification adjustment, and it is not a breaking change, because the implementations already behavior in the way which is specified with this change.

@eernstg eernstg requested a review from lrhn October 1, 2024 16:13
@@ -6661,7 +6666,7 @@ \subsubsection{Applicability of an Extension}
because they do not have a type.%
}
\item
The type $S$ does not have a member with the basename $m$,
The type $S$ does not have an instance member with the basename $m$,
Copy link
Member

@lrhn lrhn Oct 1, 2024

Choose a reason for hiding this comment

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

Do we have a name for "the set of instance members of a type"? I sometimes use "type interface" or "type member signatures".
It's the signatures of the members that a typed member access/invocation can access on a receiver with that type as static type.
(Because that's the kind of members this text is talking about. Not declarations, not concrete "instance members", just the things that can be accessed on something with that static type.)

Copy link
Member Author

Choose a reason for hiding this comment

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

We do use "members of" a library, class, mixin, or enumerated type, "instance members of" a class or extension, "static members of" a class or extension, "a member of" the type void, a super-bounded type, the on-type, "members for" a type, "a member of" an object.

Another branch of this terminology may be better in general: We're quite frequently talking about "the interface of" an interface type, which is considered to be a nominally identified set of member signatures.

So we do certainly talk about the members of a class or class-like entity, explicitly mentioning both of the static and instance kinds. We do also talk about the members of a type (not nearly as many times), again both kinds.

But I think it's fair to say that the elements in the interface of an interface type would be instance members, implicitly or explicitly.

I think we're OK using 'static members of a class' and 'instance members of a class', no problem, and we're pretty much OK using 'static members of an interface type' and 'instance members of an interface type', even though those occurrences should perhaps be modified to talk about the underlying class/mixin/whatever that was used to induce said type.

And I think it's fair to say that the interface of an interface type contains only instance members. We could still include the word 'instance' to double down on the disambiguation.

Copy link
Member

Choose a reason for hiding this comment

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

Indeed. The issue here is that the on type of an extension may not be an interface type, and yet I want to talk about the interface of it, meaning the set of member signatures that it has. (Which includes the "members of Object", for function types an instance method names call, for record types instance getters for each field, and for extension types, the extension members of the type.

If we could consistently say "the type signature of at type" to mean that set of member signatures, then that could make some things much easier to talk about. (And the type interface/signature of an interface type is the interface type's interface members, unsurprisingly.)

(I've considered "type interface" and "type signature", but I like "signature" better because it matches "member signature", which is itself a useful abstraction over something with a name and a way to use it - getter, setter, or method so far.)

Copy link
Member Author

Choose a reason for hiding this comment

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

If we could consistently say "the type signature of at type" to mean that set of member signatures

I've used "the interface of a type" with that intended meaning many times. The specification does say "interface type" in a number of situations, but I don't see a problem with a slightly more forgiving use of this phrase that includes some non-interface types with the Object members as the interface. Record types is a good example, they certainly do have getters named in ways like $1 and $foo, and I don't see why we should special case them in the situation where we just want to talk about the available static information about instance members.

@eernstg eernstg merged commit 8c4aa8a into main Oct 2, 2024
4 checks passed
@eernstg eernstg deleted the specify_applicability_static_oct24 branch October 2, 2024 08:05
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