-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Spec: Refactoring: Merge "definitions" and "declarations". #18259
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
Conversation
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 LGTM, nice refactoring!
docs/_spec/04-basic-definitions.md
Outdated
However, there is a restriction on forward references in blocks: | ||
In a statement sequence ´s_1 ... s_n´ making up a block, if a simple name in ´s_i´ refers to an entity defined by ´s_j´ where ´j \geq i´, then for all ´s_k´ between and including ´s_i´ and ´s_j´, | ||
|
||
- ´s_k´ cannot be a variable definition. | ||
- If ´s_k´ is a value definition, it must be lazy. | ||
|
||
Moreover, in a block, all definitions must be concrete, and opaque type alias definitions are not allowed. |
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's not very useful, but abstract type definitions are allowed in blocks.
docs/_spec/04-basic-definitions.md
Outdated
@@ -457,7 +452,7 @@ Variance annotations indicate how instances of parameterized types vary with res | |||
A ‘+’ variance indicates a covariant dependency, a ‘-’ variance indicates a contravariant dependency, and a missing variance indication indicates an invariant dependency. | |||
|
|||
A variance annotation constrains the way the annotated type variable may appear in the type or class which binds the type parameter. | |||
In a type definition `type ´T´[´\mathit{tps}\,´] = ´S´`, or a type declaration `type ´T´[´\mathit{tps}\,´] >: ´L´ <: ´U´` type parameters labeled ‘+’ must only appear in covariant position whereas type parameters labeled ‘-’ must only appear in contravariant position. | |||
In a type definition `type ´T´[´\mathit{tps}\,´] = ´S´`, `type ´T´[´\mathit{tps}\,´] >: ´L´ <: ´U´` or `type ´T´[´\mathit{tps}\,´] >: ´L´ <: ´U´ = ´S´`, type parameters labeled ‘+’ must only appear in covariant position whereas type parameters labeled ‘-’ must only appear in contravariant position. |
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.
In a type definition `type ´T´[´\mathit{tps}\,´] = ´S´`, `type ´T´[´\mathit{tps}\,´] >: ´L´ <: ´U´` or `type ´T´[´\mathit{tps}\,´] >: ´L´ <: ´U´ = ´S´`, type parameters labeled ‘+’ must only appear in covariant position whereas type parameters labeled ‘-’ must only appear in contravariant position. | |
In a type definition `type ´T´[´\mathit{tps}\,´] = ´S´`, `type ´T´[´\mathit{tps}\,´] >: ´L´ <: ´U´` or `opaque type ´T´[´\mathit{tps}\,´] >: ´L´ <: ´U´ = ´S´`, type parameters labeled ‘+’ must only appear in covariant position whereas type parameters labeled ‘-’ must only appear in contravariant position. |
docs/_spec/04-basic-definitions.md
Outdated
A parameter signature consists of an optional type parameter clause `[´\mathit{tps}\,´]`, followed by zero or more value parameter clauses `(´\mathit{ps}_1´)...(´\mathit{ps}_n´)`. | ||
Such a declaration or definition introduces a value with a (possibly polymorphic) method type whose parameter types and result type are as given. | ||
Such a definition introduces a method with a type (if there is no type or term parameter clause) or methodic type whose parameter types and result type are as given (otherwise). |
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.
This sentence is hard to parse, are we distinguishing "method with a type" versus "method with a methodic type"? Could the former be called "method with a proper type" to avoid confusion?
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.
Is it better now?
docs/_spec/04-basic-definitions.md
Outdated
@@ -580,11 +573,11 @@ A unary operator is a method named `"unary_´op´"` where ´op´ is one of `+`, | |||
|
|||
### Default Arguments | |||
|
|||
Each value parameter declaration may optionally define a default argument. | |||
Each formal value parameter may optionally define a default argument. |
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 looks like the spec uses both "formal parameter" and "parameter" interchangeably, either seems fine (as long as arguments are called arguments and not parameters), but it'd be preferable to stick to one terminology (e.g. just below "for every parameter").
Previously, abstract members were syntactically separate from concrete members, and referred to "declarations", as opposed to "definitions". In this commit, all of them become "definitions". There are abstract definitions and concrete definitions. They share their syntactic productions. This will allow to more easily introduce more kinds of definitions that can be abstract or concrete in deeper productions of the grammar, such as extension methods.
445c8e2
to
86d06b4
Compare
Previously, abstract members were syntactically separate from concrete members, and referred to "declarations", as opposed to "definitions".
In this commit, all of them become "definitions". There are abstract definitions and concrete definitions. They share their syntactic productions.
This will allow to more easily introduce more kinds of definitions that can be abstract or concrete in deeper productions of the grammar, such as extension methods.
Tentatively assigning to @smarter