digitalmars.D - D grammar oddities
- Dibyendu Majumdar (3/3) Nov 16 2020 struct and unions aren't types.
- H. S. Teoh (5/9) Nov 16 2020 Link?
- Paul Backus (6/9) Nov 16 2020 A struct declaration *creates* a type, but it is not, itself, a
- Dibyendu Majumdar (5/9) Nov 17 2020 Sure - but the issue is the grammar is useless for trying to
- Dibyendu Majumdar (3/12) Nov 17 2020 wrong link - sorry - just look for Type production in the grammar
- Paul Backus (14/23) Nov 17 2020 I assume this is the production you mean:
- user1234 (15/19) Nov 16 2020 Correct, They are declarations. For their declarations an
struct and unions aren't types. function and delegate are not either. According to the grammar.
Nov 16 2020
On Mon, Nov 16, 2020 at 11:55:29PM +0000, Dibyendu Majumdar via Digitalmars-d wrote:struct and unions aren't types. function and delegate are not either. According to the grammar.Link? T -- Creativity is not an excuse for sloppiness.
Nov 16 2020
On Monday, 16 November 2020 at 23:55:29 UTC, Dibyendu Majumdar wrote:struct and unions aren't types. function and delegate are not either. According to the grammar.A struct declaration *creates* a type, but it is not, itself, a type. When you declare `struct MyStruct { /* ... */ }`, the type that's created is just called `MyStruct`--which means that, grammatically, the type is an identifier.
Nov 16 2020
On Tuesday, 17 November 2020 at 00:24:20 UTC, Paul Backus wrote:A struct declaration *creates* a type, but it is not, itself, a type. When you declare `struct MyStruct { /* ... */ }`, the type that's created is just called `MyStruct`--which means that, grammatically, the type is an identifier.Sure - but the issue is the grammar is useless for trying to understand the language. There is a production Types -> .... But it isn't map to a type. https://dlang.org/spec/grammar.html#types
Nov 17 2020
On Tuesday, 17 November 2020 at 22:01:16 UTC, Dibyendu Majumdar wrote:On Tuesday, 17 November 2020 at 00:24:20 UTC, Paul Backus wrote:wrong link - sorry - just look for Type production in the grammarA struct declaration *creates* a type, but it is not, itself, a type. When you declare `struct MyStruct { /* ... */ }`, the type that's created is just called `MyStruct`--which means that, grammatically, the type is an identifier.Sure - but the issue is the grammar is useless for trying to understand the language. There is a production Types -> .... But it isn't map to a type. https://dlang.org/spec/grammar.html#types
Nov 17 2020
On Tuesday, 17 November 2020 at 22:04:34 UTC, Dibyendu Majumdar wrote:I assume this is the production you mean: https://dlang.org/spec/grammar.html#Type I don't understand why you'd say that this is "useless." It is perfectly useful if you want to understand how to refer to a type syntactically--for example, in a variable declaration, or when passing it as an argument to a template. Is your complaint that a description of the language's *syntax* does not do anything to help you understand its *semantics*? If so, that's certainly true, but I'm not sure why you'd expect it to. The job of the grammar is only to explain the language's syntax. Explaining the semantics of D is what the other pages in the language spec are for.Sure - but the issue is the grammar is useless for trying to understand the language. There is a production Types -> .... But it isn't map to a type. https://dlang.org/spec/grammar.html#typeswrong link - sorry - just look for Type production in the grammar
Nov 17 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.functionSame 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 TypeSuffixAccording to the grammar.
Nov 16 2020