-
Notifications
You must be signed in to change notification settings - Fork 49
abstract method decls; explicit_method_decls provisional feature
#386
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
Open
lwaern-intel
wants to merge
5
commits into
intel:main
Choose a base branch
from
lwaern-intel:lw/explicit_method_decls
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
02dd53e
abstract method decl; `explicit_method_decls` provisional feature
lwaern-intel 0a22cd3
Address trivial feedback
lwaern-intel e6f1c3a
Document abstract method declarations
lwaern-intel fbd0602
Releasenote
lwaern-intel bd207f5
Simplify the implementation with certain compromises
lwaern-intel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1798,13 +1798,37 @@ handled: | |
| * A method can only be overridden by another method if it is declared | ||
| `default`. | ||
|
|
||
| All declarations of the same method in an object must share the same signature: | ||
| every declaration must share input parameters, return value types, agree on | ||
| whether the method throws, and agree on every method qualifier except | ||
| `shared` (such as [`independent`](#independent-methods)). | ||
|
Comment on lines
+1803
to
+1804
Contributor
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. shorter and more explicit to just spell out the list: |
||
|
|
||
| > [!NOTE] | ||
| > An overridable built-in method is defined by a template | ||
| > named as the object type. So, if you want to write a template that | ||
| > overrides the `read` method of a register, and want to make | ||
| > your implementation overridable, then your template must explicitly | ||
| > instantiate the `register` template using a statement `is | ||
| > register;`. | ||
| > Overridable built-in methods are often defined by a template named as the | ||
| > object type. For example, if you want to write a template that overrides the | ||
| > `read_register` method of a register, then your template must explicitly | ||
| > instantiate the `register` template using | ||
| > <code>template <em>name</em> is (register) { ... }</code>. | ||
|
|
||
| ### Abstract method declarations | ||
| A method may be declared abstractly, imposing a requirement that some definition | ||
| of that method, by some part of the device model, is provided to the object the | ||
| abstract declaration is a member of. If that requirement is not satisfied then | ||
| the device model will be rejected by the compiler. | ||
|
|
||
| The following is an example of an abstract method declarations: | ||
| ``` | ||
| method m(uint32 a, bool b) -> (uint8, uint16) throws; | ||
| ``` | ||
|
|
||
| Similarly to [untyped abstract parameter declarations](#parameters-detailed), a | ||
| non-`shared` abstract method declaration may be specified regardless of what | ||
| other declarations of that method there are in the model, except that it is | ||
| still subject to the requirement that every declaration of the same method must | ||
| share the same signature. In contrast, [`shared` abstract method | ||
| declarations](#shared-methods) may only be specified if there is no previous | ||
| ([lower or equal ranked](#resolution-of-overrides)) `shared` declaration of that | ||
| method. | ||
|
|
||
| ### Calling Methods | ||
|
|
||
|
|
@@ -2829,19 +2853,21 @@ incomplete description can be found in the [section on templates](#templates). | |
| *dominates* the set if it has higher rank than all other | ||
| declarations in the set. Abstract `param` declarations (<code>param | ||
| <em>name</em>;</code> or <code>param <em>name</em> : | ||
| <em>type</em>;</code>) and abstract method definitions (<code>method | ||
| <em>type</em>;</code>) and abstract method declarations (<code>method | ||
| <em>name</em>(<em>args...</em>);</code>) are excluded here; they | ||
| cannot dominate a set, and a dominating declaration in a set does | ||
| not need to have higher declaration than any abstract `param` or | ||
| `method` declaration in the set. | ||
| * There may be any number of *untyped* abstract definitions of a | ||
| * There may be any number of *untyped* abstract declarations of a | ||
| parameter (<code>param <em>name</em>;</code>). | ||
| * There may be at most one *typed* abstract definition of a parameter | ||
| (<code>param <em>name</em> : <em>type</em>;</code>) | ||
| * There may be at most one abstract shared definition of a method. Any | ||
| * There may be any number of *non-shared* abstract declarations of a | ||
| method. | ||
| * There may be at most one abstract shared declaration of a method. Any | ||
| other *shared* definition of this method must have higher rank than | ||
| the abstract definition, but any rank is permitted for non-shared | ||
| definitions. For instance: | ||
| declarations. For instance: | ||
|
|
||
| ``` | ||
| template a { | ||
|
|
@@ -2855,7 +2881,7 @@ incomplete description can be found in the [section on templates](#templates). | |
| shared method m(); | ||
| } | ||
| template bb is b { | ||
| // Error: abstract shared definition overrides non-abstract | ||
| // Error: abstract shared declaration overrides non-abstract | ||
| shared method m(); | ||
| } | ||
| ``` | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
should we warn that the provisional feature is unstable? My interpretation of our view is that people are free to play around with it and give feedback, but that we strongly discourage any use in production code (maybe with the exception for Gustav, but he knows that already).