j3-fortran / generics

BSD 3-Clause "New" or "Revised" License
36 stars 8 forks source link

Use ABSTRACT keyword to indicate an abstract deferred type, in order to resolve issues with the distinction of deferred-type vs deferred-class #120

Closed aury6623 closed 4 weeks ago

aury6623 commented 1 month ago

There are inconsistencies with the usage of "deferred type"/\<deferred-type> and "deferred class"/\<deferred-class>

In the third of those 3 snippets, we assume that "deferred type" and "deferred class" are mutually exclusive categories. However, in the first snippet, as well as the section headers in the document, we refer to both things together as "deferred type". We also say "can appear in a \<type-spec>" in the first snippet, which is not true of deferred class. We also group them in the BNF, such as "\<deferred-type-declaration-stmt>" which is either TYPE, DEFERRED or CLASS, DEFERRED. We need to be more precise with the terms here.

In the existing standard, "class" is not a term used to describe a type, and it's not really even a word used to describe a data object. I think the closest it gets to that is the "CLASS IS" syntax in a \<type-guard-stmt>. CLASS is only a type specifier which declares polymorphic data objects. I think our problem might be the use of the word "class" at all to describe the concept we want; when I see CLASS in Fortran, I think "declaration of an object", not "definition of a type".

The TYPE, DEFERRED :: type-name declaration is supposed to be analogous to the TYPE :: type-name construct, right? So I think it would be more clear to use TYPE, ABSTRACT, DEFERRED :: type-name as the declaration, analogous to TYPE, ABSTRACT :: type-name.

With that notion, this PR is my proposal to address the inconsistencies between \<deferred-type> and \<deferred-class>.

If the TYPE, ABSTRACT, DEFERRED :: type-name syntax is not preferred, we could still revert back to the CLASS, DEFERRED :: type-name syntax and keep everything else in this edit the same, except the normative text would change to:

If [[ABSTRACT appears -> CLASS is used]] in \<deferred-type-declaration-stmt>, the declared deferred types act as if they were abstract extensible derived types. Otherwise, they act as if they were non-extensible types.

everythingfunctional commented 1 month ago

I'm coming around to @aury6623 's proposal here. I think we should go ahead and include extensible while we're at it. I think I've worked out exactly what is needed for all this, so I'll have something submitted later today.

everythingfunctional commented 4 weeks ago

Addressed by #131