Prev: Floating Point Multiplication - 32 and 64 bit differences
Next: Clarify An Old Question: define a user data containing array with dimensions decided in running time
From: Tobias Burnus on 18 May 2010 13:17 Hi all, the Fortran 2003 standard (and the Fortran 2008 FDIS) permit that a type name is the same as a generic name, allowing to write a "constructor" to use a term from other programming languages. In words of the standard: "12.3.2 Specification of the procedure interface" [...] "A generic name may be the same as a derived-type name, in which case all of the procedures in the interface block shall be functions." Additionally, one finds the following constraint: R457 structure-constructor is derived-type-spec ( [ component-spec-list ] ) C489 (R457) If derived-type-spec is a type name that is the same as a generic name, the component-spec-list shall not be a valid actual-arg-spec-list for a function reference that is resolvable as a generic reference (12.4.4.1). I have problems to read the constraint. What happens if the list *is* resolvable as generic reference? Is this then just not a structure constructor? Namely, the compiler simply checks whether it matches as generic reference and if not tries whether it is a valid structure constructor? Or does this also impose constraints on which interface generic procedures are allowed? I think it is the former, as my interpretation is oscillating between the two interpretations, I though it is better to ask. Tobias
From: Richard Maine on 18 May 2010 14:19
Tobias Burnus <burnus(a)net-b.de> wrote: > R457 structure-constructor > is derived-type-spec ( [ component-spec-list ] ) > > C489 (R457) If derived-type-spec is a type name that is the same as a > generic name, the component-spec-list shall not be a valid > actual-arg-spec-list for a function reference that is resolvable as a > generic reference (12.4.4.1). > > I have problems to read the constraint. What happens if the list *is* > resolvable as generic reference? Is this then just not a structure > constructor? Correct. I recognize it is sort of a confusingly backwards way for the standard to express it, but I'm afraid that is typical of standard-speak. Perhaps a short note would have been in order. Without this constraint, it would be ambiguous whether one had a function reference or a constructor. For a user, I think describing it from a different perspective might be more clear. Perhaps say that you can write something that looks like this, which is interpreted as a function reference if possible, or otherwise as a constructor. But that's not the way the standard usually expresses things. -- Richard Maine | Good judgment comes from experience; email: last name at domain . net | experience comes from bad judgment. domain: summertriangle | -- Mark Twain |