(j3.2006) parentheses around a variable that is an /expr/
Van Snyder
Van.Snyder
Thu Dec 10 14:17:46 EST 2009
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.
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
More information about the J3
mailing list