spec: consolidate the definition of "defined types" #45587
The spec says:
TypeDef = identifier Type .
Also, whenever "defined type(s)" appears in the spec, it is linked to the definition above.
A reader may wrongly think that all defined types are created by type definition. But this is not true, because types such as
And if a reader wants to fully understand what defined types are, the reader has to read all sections below.
The problem is that the definition of "defined types" is not contained in one place of the spec.
Adding a section or a paragraph just for the definition of "defined types" would help readers to understand the concept correctly and easily.
I would suggest adding a section "Defined types" before the section "Type identity" so that the new section belongs to Properties of types and values and Type identity section can naturally refer to "defined types".
The new section should look like this. I don't think this is good enough, but I just wanted to show my idea clearly.
Also, I suggest
- The new type is called a defined type. + The new type is a defined type.
to reduce the misunderstanding that "the new type" is the definition of "a defined type".
The text was updated successfully, but these errors were encountered:
This is about clarity of the spec, I believe.
Fundamentally, the problem is the term "defined type" (and I am guilty as charged) which does not describe those types well. Originally, these types were called "named types" which also applied to the built-in types (since they have names). But when we introduced type aliases this didn't work well anymore because a type alias is clearly "named" yet it may (or may not be) a "defined type" (or a "named type" in the original sense).
In retrospect, I believe the better term would have been "nominal type" which describes types whose properties are associated with their name rather than their structure. A type may be named (= have a name) and refer to a nominal or structural type. Built-in types and types declared by non-alias type declarations are nominal types.
In my humble opinion,
So changing the name again might bring more confusion.
Another solution could be just to state "Each predeclared type are a defined type if it's not a type alias" in the "Types" or "Predeclared identifiers" section.
Then a reader will have to read 2 places to fully understand what the define type is , but it would be much better than the current situation.