class grammar
Nick
my_dlang at bestmail.us
Fri May 7 21:06:45 UTC 2021
On Friday, 7 May 2021 at 19:33:30 UTC, Basile B. wrote:
> 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.
Okay. So, although the base class list grammar is permissive, the
restricted semantics of this list is indicated by its optional
elements being explicitly named 'SuperClass' (class) and
'Interface' (interface). I now see how the 'QualifiedIdentifier'
and 'Typeof' grammar could apply if these semantics are taken
into account.
More information about the Digitalmars-d-learn
mailing list