(j3.2006) parentheses around a variable that is an /expr/

Van Snyder Van.Snyder
Thu Dec 10 14:26:13 EST 2009


On Thu, 2009-12-10 at 11:17 -0800, Van Snyder wrote:
> Suppose you wrote a function that didn't have the pointer attribute on
> its result or its dummy argument.  Suppose you gave that function a
> defined operator generic ID something like .NOTHING.  When you invoked
> it as .NOTHING. x its result would not have the pointer attribute.
> 
> Parentheses are the same thing, just spelled differently (and the
> compiler already knows the function body and how to inline it).
> 
> Other languages in fact let you define a function to attach to the
> "generic ID" (...).  Fortran has chosen not to do that.
> 
> There used to be either a normative statement or a note that an
> expression enclosed in parentheses doesn't have the pointer attribute,
> but I can't find it now.  Maybe it got taken out.

I can't find the text I remembered, but maybe 7.1.9.2p3, especially the
second bullet in the list, was considered to be enough.  Note 12.9 says
an expression enclosed in parentheses does not have the POINTER or
ALLOCATABLE attribute (and presumably not the TARGET attribute, and
probably several others).  It still has the DIMENSION attribute, but
can't be subscripted.  How about ASYNCHRONOUS or VOLATILE?

> On Wed, 2009-12-09 at 22:56 -0800, Robert Corbett wrote:
> > We recently started our implementation of /expr/s as variables (R602).
> > A question arose regarding whether or not an /expr/ used as a variable
> > could be enclosed in parentheses.  Constraint C602 states
> > 
> >      /expr/ shall be a reference to a function that has a pointer
> >      result.
> > 
> > Section 1.3.111.2 states
> > 
> >      function reference
> >      appearance of the procedure designator for a function, or
> >      operator symbol in a context requiring execution of the
> >      function during expression evaluation (12.5.3)
> > 
> > A naive reading of that section is that the procedure
> > designator or operator symbol is the function reference.  That
> > reading is clearly nonsensical.  A possible interpretation is
> > that the "context requiring exection of the function" is the
> > function reference.  Under that interpretation, the context
> > might include a parenthesized /fuinction-reference/.
> > Section 12.5.3, on the other hand, appears to allow only a
> > /function-reference/ or an application of an operator as a
> > function reference, which would exclude enclosing parentheses.
> > 
> > Is the intent that a variable that is an /expr/ is allowed to
> > be parenthesized?  Should the example
> > 
> >        (1 + P) = X
> > 
> > be considered standard-conforming Fortran 2008 code assuming
> > that + in this context returns a pointer to a numeric object,
> > or should only the unparenthesized form
> > 
> >        1 + P = X
> > 
> > be allowed?
> > 
> > Robert Corbett
> > _______________________________________________
> > J3 mailing list
> > J3 at j3-fortran.org
> > http://j3-fortran.org/mailman/listinfo/j3
> 
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3




More information about the J3 mailing list