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 instantiation of objects with abstract methods #1355

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions p4-16/spec/P4-16-spec.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2765,7 +2765,7 @@ either by the number of arguments or by the names of the arguments,
when calls are specifying argument names. Argument type information
is not used in disambiguating calls.

Notice that overloading of parsers, controls, or packages is not allowed:
Notice that overloading of abstract methods, parsers, controls, or packages is not allowed:
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just point out this forbids overloading of abstract methods completely, i.e. also by the number of arguments. I am OK with that, but I wanted to highlight that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it was intended because allowing overload via only the arity, and only for abstract methods, would be too complex. But in some future, if someone finds such a feature useful, we might consider lift this restriction then.


[source,p4]
----
Expand Down Expand Up @@ -5415,10 +5415,15 @@ include::grammar.adoc[tag=objDeclarations]
include::grammar.adoc[tag=objDeclaration]
----

Abstract method implementations must use the same number of parameters, and
the same parameter directions as those declared in the extern object declaration.
Note that overloading of abstract methods is not allowed, thus an
implementation could be matched to a declaration only with the method name.

The abstract methods can only use the supplied arguments or refer to
values that are in the top-level scope. When calling another method
of the same instance the `this` keyword is used to indicate the
current object instance:
values that are in the same initializer block or the top-level scope.
When calling another method of the same instance the `this` keyword is
used to indicate the current object instance:

[source,p4]
----
Expand Down