(j3.2006) Specification functions
Bill Long
longb
Fri Feb 24 17:21:03 EST 2017
My reading is the same as Steve?s. You have have a recursive function and not call it recursively in a particular situation. If recursive were banned, there would be a serious problem with existing specification functions when the default becomes recursive in f2015.
On Feb 24, 2017, at 4:13 PM, Steidel, Jon L <jon.l.steidel at intel.com> wrote:
> 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.
Well, that was a restriction in f95. It was removed in f03. Documentation does tend to become obsolete over time.
Cheers,
Bill
>
> -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> 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
>
>
>
> --
> .
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3
Bill Long longb at cray.com
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101
More information about the J3
mailing list