(j3.2006) Is a parenthesized polymorphic defined operation apolymorphic primary?
Malcolm Cohen
malcolm
Tue Mar 24 04:10:39 EDT 2015
Of course it's polymorphic. Parenthesising something does not change the
declared type, dynamic type, or any of the type parameters.
I mean sure we don't come right out and say ANY of that stuff, but it's implicit
in the common and mathematical meanings of parentheses. We don't even say that
(1.5) is type REAL for goodness sake, that doesn't mean that it becomes
CHARACTER with LEN=3.
The user is absolutely correct. It would be sheer madness to have
O1 + O2 + O3
have a type different from
(O1 + O2) + O3
You write
<<<
Because defining when a
parenthesized expression is polymorphic would require
consideration of the nature of the contained expression
that is not spelled out in the standard
>>>
no it does not require any special consideration. "(anything)" has the same
type, type parameters, and value, as "anything". Parenthesising something is
not an operation ***therefore it cannot change anything about the parenthesised
entity*** other than potentially changing it from a object reference into an
object value.
Cheers,
-----Original Message-----
From: Robert Corbett
Date: ?? 27?3?24? 16:10
To: j3
Subject: (j3.2006) Is a parenthesized polymorphic defined operation apolymorphic
primary?
A user has written a program in which he has used parentheses
to group the operands of an expression that consists of
two applications of a polymorphic defined operation:
O4 = O1 + (O2 + O3)
The operations turn into calls of a function that has a
polymorphic allocatable result variable. Oracle Solaris
Studio Fortran assumes that the parenthesized expression is
not polymorphic, and so considers the dynamic type of the
parenthesized expression to be the same as the declared
type of the function result variable. The user assumes
the dynamic type of the parenthesized expression should
be the same as the dynamic type of the expression without
the parentheses.
Paragraph 2 of Clause 7.1.9.1 of the Fortran 2008 standard
states:
If an expression is a polymorphic primary or
defined operation, the type parameters and the
declared and dynamic types of the expression
are the same as those of the primary or defined
operation.
The question of whether the dynamic type of a parenthesized
expression is the same as the declared type or the dynamic
type of the contained expression depends on whether the
parenthesized expression is considered a polymorphic
primary. The standard does not appear to supply an explicit
answer to that question. Because defining when a
parenthesized expression is polymorphic would require
consideration of the nature of the contained expression
that is not spelled out in the standard, I assume that a
parenthesized expression is not intended to be a
polymorphic primary.
Robert Corbett
_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org
http://mailman.j3-fortran.org/mailman/listinfo/j3
________________________________________________________________________
This e-mail has been scanned for all viruses by Star.
________________________________________________________________________
--
................................Malcolm Cohen, Nihon NAG, Tokyo.
More information about the J3
mailing list