[J3] Can a procedure pointer have character(*) result type?

Malcolm Cohen malcolm at nag-j.co.jp
Wed Nov 30 23:52:53 UTC 2022


Hi Daniel,

 

Your assertion that a function pointer is not a function is not supported by any normative text.

 

Indeed the very definition of “procedure pointer” states that it is a procedure with the POINTER attribute, i.e. all procedure pointers are procedures.

 

A procedure is either a function (if typed) or a subroutine (which has no type). Thus it follows that a subroutine with the POINTER attribute would be a subroutine pointer, and that a function with the POINTER attribute would be a function pointer.

 

Note that the constraint has “function name”, thus applies to all named functions. It is not a BNF term limited to some context – it applies to *ALL* functions.

 

Cheers,

-- 

..............Malcolm Cohen, NAG Oxford/Tokyo.

 

From: Daniel C Chen <cdchen at ca.ibm.com> 
Sent: Thursday, December 1, 2022 1:24 AM
To: Clune, Thomas L. (GSFC-6101) <thomas.l.clune at nasa.gov>; General J3 interest list <j3 at mailman.j3-fortran.org>; Long, Bill F <william.long at hpe.com>
Cc: Malcolm Cohen <malcolm at nag-j.co.jp>
Subject: RE: [J3] Can a procedure pointer have character(*) result type?

 

Hi Tom,
I think in R803, the function-name is indeed a function name. However, I don’t think a procedure pointer name is a function name nor it should fall into this rule. I think it should be object-name in this particular BNF. This is also the reason I can’t see C724 applies to procedure pointer. I could be wrong though.
Thanks,
Daniel

 

From: Clune, Thomas L. (GSFC-6101) <thomas.l.clune at nasa.gov <mailto:thomas.l.clune at nasa.gov> > 
Sent: November 30, 2022 10:35 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org <mailto:j3 at mailman.j3-fortran.org> >; Long, Bill F <william.long at hpe.com <mailto:william.long at hpe.com> >
Cc: Daniel C Chen <cdchen at ca.ibm.com <mailto:cdchen at ca.ibm.com> >; Malcolm Cohen <malcolm at nag-j.co.jp <mailto:malcolm at nag-j.co.jp> >
Subject: Re: [EXTERNAL] Re: [J3] Can a procedure pointer have character(*) result type?

 

Daniel, I think the constraint does disallow the procedure pointer case. This is a special case of type-declaration-stmt. R801: type-declaration-stmt is declaration-type-spec [ [ , attr-spec ] .. . :: ] entity-decl-list Where R803 entity-decl 

ZjQcmQRYFpfptBannerStart




This Message Is From an External Sender 


This message came from outside your organization. 

ZjQcmQRYFpfptBannerEnd

Daniel,

 

I think the constraint does disallow the procedure pointer case.     This is a special case of type-declaration-stmt.

R801: type-declaration-stmt is declaration-type-spec [ [ , attr-spec ] ... :: ] entity-decl-list

 

Where 

R803 entity-decl is object-name [ ( array-spec ) ]

     [ lbracket coarray-spec rbracket ]

    [ * char-length ] [ initialization ]

    or function-name [ * char-length ]

 

The “or” clause in R803 is the one that applies in C724.   I.e., the POINTER case has a function name that is not necessarily related to that of the target procedure.

 

Cheers,

*	Tom

 

From: J3 <j3-bounces at mailman.j3-fortran.org <mailto:j3-bounces at mailman.j3-fortran.org> > on behalf of j3 <j3 at mailman.j3-fortran.org <mailto:j3 at mailman.j3-fortran.org> >
Reply-To: j3 <j3 at mailman.j3-fortran.org <mailto:j3 at mailman.j3-fortran.org> >
Date: Wednesday, November 30, 2022 at 10:11 AM
To: "Long, Bill F" <william.long at hpe.com <mailto:william.long at hpe.com> >, j3 <j3 at mailman.j3-fortran.org <mailto:j3 at mailman.j3-fortran.org> >
Cc: Daniel C Chen <cdchen at ca.ibm.com <mailto:cdchen at ca.ibm.com> >, Malcolm Cohen <malcolm at nag-j.co.jp <mailto:malcolm at nag-j.co.jp> >
Subject: [EXTERNAL] Re: [J3] Can a procedure pointer have character(*) result type?

 

Hi Bill,
It should be C724 in F2018.
It states:
“C724 A function name declared with an asterisk type-param-value shall not be an array, a pointer, elemental, or pure. A function name declared with an asterisk type-param-value shall not have the RECURSIVE attribute.”

I am not sure how it disallows the procedure pointer case.
Thanks,
Daniel

From: Long, Bill F <william.long at hpe.com <mailto:william.long at hpe.com> > 
Sent: November 30, 2022 9:43 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org <mailto:j3 at mailman.j3-fortran.org> >
Cc: Daniel C Chen <cdchen at ca.ibm.com <mailto:cdchen at ca.ibm.com> >; Malcolm Cohen <malcolm at nag-j.co.jp <mailto:malcolm at nag-j.co.jp> >
Subject: [EXTERNAL] Re: [J3] Can a procedure pointer have character(*) result type?

 

Which version of the standard is this C723 from? Does not look anything like the C723 in either F2018 or N2209. Also, I suspect the omitted .. . text effectively excludes the confusing cases. Cheers, Bill From: J3 <j3-bounces@ mailman. j3-fortran. org> 

ZjQcmQRYFpfptBannerStart




This Message Is From an External Sender 


This message came from outside your organization. 

ZjQcmQRYFpfptBannerEnd

Which version of the standard is this C723 from?   Does not look anything like the C723 in either F2018 or N2209.

 

Also, I suspect the omitted ... text effectively excludes the confusing cases. 

 

Cheers,

Bill

 

 

  _____  

From: J3 <j3-bounces at mailman.j3-fortran.org <mailto:j3-bounces at mailman.j3-fortran.org> > on behalf of Daniel C Chen via J3 <j3 at mailman.j3-fortran.org <mailto:j3 at mailman.j3-fortran.org> >
Sent: Wednesday, November 30, 2022 3:13 AM
To: General J3 interest list <j3 at mailman.j3-fortran.org <mailto:j3 at mailman.j3-fortran.org> >
Cc: Daniel C Chen <cdchen at ca.ibm.com <mailto:cdchen at ca.ibm.com> >; Malcolm Cohen <malcolm at nag-j.co.jp <mailto:malcolm at nag-j.co.jp> >
Subject: Re: [J3] Can a procedure pointer have character(*) result type? 

 

Hi Malcolm,
C723 states “A function name….shall not be…, a pointer”. Is a procedure pointer name also a function name? It seems unclear to me as its procedure target can also be a subroutine.

Thanks,
Daniel

 

From: J3 <j3-bounces at mailman.j3-fortran.org <mailto:j3-bounces at mailman.j3-fortran.org> > On Behalf Of Malcolm Cohen via J3
Sent: November 30, 2022 12:21 AM
To: 'General J3 interest list' <j3 at mailman.j3-fortran.org <mailto:j3 at mailman.j3-fortran.org> >
Cc: Malcolm Cohen <malcolm at nag-j.co.jp <mailto:malcolm at nag-j.co.jp> >
Subject: [EXTERNAL] Re: [J3] Can a procedure pointer have character(*) result type?

 

Daniel writes > The question I have is regarding if a assumed-length dummy procedure pointer is allowed. No, it is not. The constraint > C723 A function name declared with an asterisk type-param-value shall not be an array, a pointer, 

Daniel writes

> The question I have is regarding if a assumed-length dummy procedure pointer is allowed. 

No, it is not.

 

The constraint

 

> C723 A function name declared with an asterisk type-param-value shall not be an array, a pointer,

 

is operational: there is no doubt that a procedure pointer is a pointer, see the definition of pointer:

 

3.108

pointer

data pointer or procedure pointer

 

Therefore assumed-length is not permitted.

 

> From an implementation viewpoint, I don't see a problem with this usage

 

I do. That comment assumes information that is not necessary to be passed is nonetheless passed. I see no reason to assume all implementations pass unnecessary information unnecessarily. (Individual implementations may have their own reasons for passing extra information.)

 

> Your example without pointer worked fine with NAG, but I get an internal compiler error (ICE) when you add it back in

 

There seems to be a missing error test. I will look into it.

 

***

 

Finally, I note that assumed-length functions were already obsolescent in Fortran 95. Procedure pointers were only added in Fortran 2003. It is the long-standing policy of the committee that unless there are good reasons to the contrary, obsolescent features will not be enhanced.

 

So it is not a surprise that we did not add this feature.

 

Cheers,

-- 

..............Malcolm Cohen, NAG Oxford/Tokyo.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20221201/d7282ced/attachment-0001.htm>


More information about the J3 mailing list