D grammar oddities

user1234 user1234 at 12.de
Tue Nov 17 00:46:40 UTC 2020


On Monday, 16 November 2020 at 23:55:29 UTC, Dibyendu Majumdar 
wrote:
> struct and unions aren't types.

Correct, They are declarations. For their declarations an 
internal TypeStruct / TypeUnion is created. Later Identifier are 
resolved to those TypeQualified.

> function

Same principle. Function are declarations and an internal 
TypeFunction is created for the decl.

In addition when there's a need to express a function type, an 
alias must be used, for example:

alias F = void(int);

> and delegate are not either.

they are. But it's hidden as type suffix:

https://dlang.org/spec/declaration.html#TypeSuffixes

        void           delgate (int)
-------^     ---------^
BasicType    TypeSuffix


>
> According to the grammar.




More information about the Digitalmars-d mailing list