class grammar
Basile B.
b2.temp at gmx.com
Fri May 7 19:33:30 UTC 2021
On Friday, 7 May 2021 at 18:07:45 UTC, Nick wrote:
> The class grammar, as defined in the D language specification
> ...
> is not clear to me how a user-defined type (such as a class or
> interface) is also a 'BasicType' (as defined by the grammar).
> However, the compiler only accepts classes or interfaces as a
> base type.
>
Just like a natural language what is grammatically correct is not
necessarily semantically correct.
In the case of the inherithence list it's easier to choose
'BasicType' because 'TypeOf' and 'QualifiedIdentifier' can both
be solved to a class or an interface.
With this example:
```
alias B = int;
class A : B {}
```
you can see that the semantic check to reject `int` is necessary
anyway.
More information about the Digitalmars-d-learn
mailing list