(j3.2006) Specification functions

Steidel, Jon L jon.l.steidel
Fri Feb 24 17:13:40 EST 2017


I understand paragraph 6 prevents one from invoking the procedure which is being defined as a specification function inside itself (directly or indirectly).

I must not be the only one confused by this.  Our user documentation explicitly prohibits a specification function from being recursive.

-jon

From: j3-bounces at mailman.j3-fortran.org [mailto:j3-bounces at mailman.j3-fortran.org] On Behalf Of Steve Lionel
Sent: Friday, February 24, 2017 5:06 PM
To: fortran standards email list for J3 <j3 at mailman.j3-fortran.org>
Subject: Re: (j3.2006) Specification functions

I read this as prohibiting a specification function from invoking the procedure in which it is used as a specification function, not prohibiting the specification function itself from being recursive.

Steve

On Fri, Feb 24, 2017 at 5:01 PM, Steidel, Jon L <jon.l.steidel at intel.com<mailto:jon.l.steidel at intel.com>> wrote:
References are to F2008 document (10-007r1)

In section7.1.11 Specification expressions, paragraph 5 states

"A function is a specification function if it is a pure function, is not a standard intrinsic function, is not an internal function, is not a statement function, and does not have a dummy procedure argument."

Paragraph 5 goes on

"Evaluation of a specification expression shall not directly or indirectly cause a procedure defined by the subprogram in which it appears to be invoked."

 Note 7.32  which follows ends with a sentence

"The prohibition against recursion avoids the creation of a new instance of a procedure while construction of one is in process."

Nowhere in this section is there a prohibition against a recursive specification expression.  I scanned for occurrences of "recursi" and "specification expression" and found no prohibition of this elsewhere in the document.  I checked "Pure subprograms" and it appears a PURE subprogram may be recursive.   Should "is not a recursive function," be added to the list in paragraph 5?  Or should the last sentence of note 7.32 be deleted?

F2015 reads the same.  Since recursion is the default in 2015, specification functions in existing programs will need to be declared NONRECURSIVE if we really intended to disallow recursive specification functions.

I see no harm in a recursive function being used to specify a dimension in an automatic array.

-jon

_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org<mailto:J3 at mailman.j3-fortran.org>
http://mailman.j3-fortran.org/mailman/listinfo/j3



--
.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20170224/26389e1c/attachment.html 



More information about the J3 mailing list