(j3.2006) Specification functions

Van Snyder Van.Snyder
Fri Feb 24 18:47:31 EST 2017


We removed the prohibition against recursive specification functions
quite a while ago.  There would be a problem, a never-ending recursion,
if a specification function were to invoke the procedure in which a
reference to it appears.

On Fri, 2017-02-24 at 22:01 +0000, Steidel, Jon L 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
> http://mailman.j3-fortran.org/mailman/listinfo/j3





More information about the J3 mailing list