(j3.2006) a question on same_type_as and type parameters

Michael Ingrassia michaeli
Thu Aug 28 14:40:17 EDT 2008


We do not appear to be consistent in the way we throw around common notions
like "same" in the standard.  I would be hesitant to conclude from
"two entities have the same type" even that "the types of the two entities are
the same" or conversely, 
since the first clause talks about entities and the second
clause talks about types.

SAME_TYPE_AS wording requires us to know when the dynamic type of A is the same as the dynamic type of B.  I'll go way out on a limb and speculate that it's
relevant to understand when two data entities have the same dynamic type.

Section 4.5.1.3p2 appears to comment on "when two data entities have
the same type".  Since that phrase goes on to say "if they are declared ..."
it is not clear that this paragraph means to comment at all on "when two
data entities have the same dynamic type".   That sounds like a trickier
notion, and there should be a paragraph somewhere to say when two data
entities have the same dynamic type.  That seems to be left to the reader
to figure out by bootstrapping from 4.5.1.3p2 using the definition
of dynamic type at 5.1.1.2p8 [76].

Applied to Jim's test case, on the assumption that it's legal,
	class(*), allocatable :: a, b
	allocate (real :: a)
	allocate(double precision :: b)
I'd get
    o a is an allocated allocatable polymorphic object
    o so dynamic type of a is "default real" by 5.1.1.2p8 1st sentence and p.38
    o b is an allocated allocatable polymorphic object
    o so dynamic type of b is "double precision real"

which reduces the argument to one we've had previously about whether
default real and double precision real are the same type.  You wouldn't
get that impression from reading page 38 of the 2003 standard.

	--Michael I.




More information about the J3 mailing list