Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

lp1 on fire (One of the more obfuscated kernel messages)


devel / comp.lang.fortran / CALL FOO when FOO is a function

SubjectAuthor
* CALL FOO when FOO is a functionpmk
+* Re: CALL FOO when FOO is a functionThomas Koenig
|`* Re: CALL FOO when FOO is a functionpmk
| +- Re: CALL FOO when FOO is a functiongah4
| `* Re: CALL FOO when FOO is a functionSteve Lionel
|  `* Re: CALL FOO when FOO is a functionDan Nagle
|   +* Re: CALL FOO when FOO is a functionpmk
|   |`* Re: CALL FOO when FOO is a functionDan Nagle
|   | +* Re: CALL FOO when FOO is a functionFortranFan
|   | |`* Re: CALL FOO when FOO is a functionDan Nagle
|   | | `* Re: CALL FOO when FOO is a functionFortranFan
|   | |  `* Re: CALL FOO when FOO is a functionDan Nagle
|   | |   +* Re: CALL FOO when FOO is a functionRon Shepard
|   | |   |`* Re: CALL FOO when FOO is a functionDan Nagle
|   | |   | `* Re: CALL FOO when FOO is a functionRon Shepard
|   | |   |  +* Re: CALL FOO when FOO is a functionJames Van Buskirk
|   | |   |  |`* Re: CALL FOO when FOO is a functionCyrmag
|   | |   |  | `- Re: CALL FOO when FOO is a functionjfh
|   | |   |  `- Re: CALL FOO when FOO is a functionDan Nagle
|   | |   `- Re: CALL FOO when FOO is a functionFortranFan
|   | +* Re: CALL FOO when FOO is a functionpmk
|   | |`- Re: CALL FOO when FOO is a functionDan Nagle
|   | `* Re: CALL FOO when FOO is a functiongah4
|   |  `* Re: CALL FOO when FOO is a functionFortranFan
|   |   `- Re: CALL FOO when FOO is a functiongah4
|   `- Re: CALL FOO when FOO is a functionFortranFan
+- Re: CALL FOO when FOO is a functiongah4
+- Re: CALL FOO when FOO is a functionFortranFan
+* Re: CALL FOO when FOO is a functionJRR
|+- Re: CALL FOO when FOO is a functionpmk
|`- Re: CALL FOO when FOO is a functionFortranFan
+- Re: CALL FOO when FOO is a functionRobin Vowels
`* Re: CALL FOO when FOO is a functionSteve Lionel
 +- Re: CALL FOO when FOO is a functiongah4
 +- Re: CALL FOO when FOO is a functionFortranFan
 +* Re: CALL FOO when FOO is a functionSteve Lionel
 |+* Re: CALL FOO when FOO is a functionCyrMag
 ||`- Re: CALL FOO when FOO is a functionSteve Lionel
 |`* Re: CALL FOO when FOO is a functionFortranFan
 | `- Re: CALL FOO when FOO is a functionSteve Lionel
 `- Re: CALL FOO when FOO is a functiongah4

Pages:12
CALL FOO when FOO is a function

<6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2254&group=comp.lang.fortran#2254

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a37:63cc:0:b0:6a0:c68b:b06d with SMTP id x195-20020a3763cc000000b006a0c68bb06dmr28578qkb.90.1652888398879;
Wed, 18 May 2022 08:39:58 -0700 (PDT)
X-Received: by 2002:a81:6145:0:b0:2f1:7a81:83f with SMTP id
v66-20020a816145000000b002f17a81083fmr31570265ywb.366.1652888398722; Wed, 18
May 2022 08:39:58 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 18 May 2022 08:39:58 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=12.154.207.45; posting-account=hzJ1nwoAAACS3IxtuAkjIfQoNdylflgH
NNTP-Posting-Host: 12.154.207.45
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
Subject: CALL FOO when FOO is a function
From: pmklausler@gmail.com (pmk)
Injection-Date: Wed, 18 May 2022 15:39:58 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1453
 by: pmk - Wed, 18 May 2022 15:39 UTC

Only one Fortran compiler can cope with this usage -- most crash hard with internal errors -- but I contend that it's conforming usage.

module m
contains
function foo()
procedure(bar), pointer :: foo
foo => bar
call foo ! <-- CALL of a function
end function
subroutine bar
print *, 'in bar'
end subroutine
end module

program demo
use m
procedure(bar), pointer :: p
p => foo()
call p
end

Re: CALL FOO when FOO is a function

<t6352u$uts$1@newsreader4.netcologne.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2255&group=comp.lang.fortran#2255

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-c475-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoenig@netcologne.de (Thomas Koenig)
Newsgroups: comp.lang.fortran
Subject: Re: CALL FOO when FOO is a function
Date: Wed, 18 May 2022 15:58:22 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <t6352u$uts$1@newsreader4.netcologne.de>
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
Injection-Date: Wed, 18 May 2022 15:58:22 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-c475-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:c475:0:7285:c2ff:fe6c:992d";
logging-data="31676"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Wed, 18 May 2022 15:58 UTC

pmk <pmklausler@gmail.com> schrieb:

> Only one Fortran compiler can cope with this usage -- most crash
> hard with internal errors -- but I contend that it's conforming
> usage.

On what grounds?

> module m
> contains
> function foo()
> procedure(bar), pointer :: foo
> foo => bar
> call foo ! <-- CALL of a function
> end function
> subroutine bar
> print *, 'in bar'
> end subroutine
> end module
>
> program demo
> use m
> procedure(bar), pointer :: p
> p => foo()
> call p
> end

Sounds fishy, at least...

Re: CALL FOO when FOO is a function

<a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2256&group=comp.lang.fortran#2256

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ad4:5cc3:0:b0:461:b726:4ce with SMTP id iu3-20020ad45cc3000000b00461b72604cemr403824qvb.93.1652890033042;
Wed, 18 May 2022 09:07:13 -0700 (PDT)
X-Received: by 2002:a81:174b:0:b0:2fe:fad1:2b80 with SMTP id
72-20020a81174b000000b002fefad12b80mr105821ywx.5.1652890032849; Wed, 18 May
2022 09:07:12 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 18 May 2022 09:07:12 -0700 (PDT)
In-Reply-To: <t6352u$uts$1@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=12.154.207.45; posting-account=hzJ1nwoAAACS3IxtuAkjIfQoNdylflgH
NNTP-Posting-Host: 12.154.207.45
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com> <t6352u$uts$1@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: pmklausler@gmail.com (pmk)
Injection-Date: Wed, 18 May 2022 16:07:13 +0000
Content-Type: text/plain; charset="UTF-8"
 by: pmk - Wed, 18 May 2022 16:07 UTC

> > Only one Fortran compiler can cope with this usage -- most crash
> > hard with internal errors -- but I contend that it's conforming
> > usage.
> On what grounds?

Within the body of the function FOO, the name FOO refers to its result variable. The result variable in this case is a procedure pointer to a subroutine. A CALL statement's procedure designator is allowed to be a procedure pointer.

> > module m
> > contains
> > function foo()
> > procedure(bar), pointer :: foo
> > foo => bar
> > call foo ! <-- CALL of a function
> > end function
> > subroutine bar
> > print *, 'in bar'
> > end subroutine
> > end module
> >
> > program demo
> > use m
> > procedure(bar), pointer :: p
> > p => foo()
> > call p
> > end
> Sounds fishy, at least...

Re: CALL FOO when FOO is a function

<8ecabc9a-c83b-42d7-8a13-ed55eca988e9n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2257&group=comp.lang.fortran#2257

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ae9:de43:0:b0:69f:7585:8276 with SMTP id s64-20020ae9de43000000b0069f75858276mr422634qkf.706.1652895466652;
Wed, 18 May 2022 10:37:46 -0700 (PDT)
X-Received: by 2002:a25:abc3:0:b0:64d:eafe:d61e with SMTP id
v61-20020a25abc3000000b0064deafed61emr747385ybi.218.1652895466447; Wed, 18
May 2022 10:37:46 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 18 May 2022 10:37:46 -0700 (PDT)
In-Reply-To: <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:3c2d:7174:6b35:f873;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:3c2d:7174:6b35:f873
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
<t6352u$uts$1@newsreader4.netcologne.de> <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8ecabc9a-c83b-42d7-8a13-ed55eca988e9n@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: gah4@u.washington.edu (gah4)
Injection-Date: Wed, 18 May 2022 17:37:46 +0000
Content-Type: text/plain; charset="UTF-8"
 by: gah4 - Wed, 18 May 2022 17:37 UTC

On Wednesday, May 18, 2022 at 9:07:14 AM UTC-7, pmk wrote:
> > > Only one Fortran compiler can cope with this usage -- most crash
> > > hard with internal errors -- but I contend that it's conforming
> > > usage.

> > On what grounds?

> Within the body of the function FOO, the name FOO refers to its
> result variable. The result variable in this case is a procedure pointer
> to a subroutine. A CALL statement's procedure designator is
> allowed to be a procedure pointer.

I suspect I believe that it should not be an internal compiler error, but otherwise
I might believe compilers could accept it. But there is no claim that the result
is actually executable.

Many systems have a different calling method for functions, depending
on the type, and other attributes, of a function.

A procedure pointer can point to either a function or subroutine,
but you can only call functions with it when it points to functions,
and subroutines when it points to subroutines.

And if the compiler believes that you are not doing that, it is allowed
to reject the program.

Re: CALL FOO when FOO is a function

<e56b3504-8fda-4fa0-98a1-ca50d7f4a917n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2258&group=comp.lang.fortran#2258

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ac8:7f01:0:b0:2f9:cdc:ca4f with SMTP id f1-20020ac87f01000000b002f90cdcca4fmr864296qtk.345.1652896424270;
Wed, 18 May 2022 10:53:44 -0700 (PDT)
X-Received: by 2002:a81:18cc:0:b0:2ff:4211:14a2 with SMTP id
195-20020a8118cc000000b002ff421114a2mr615895ywy.508.1652896424049; Wed, 18
May 2022 10:53:44 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 18 May 2022 10:53:43 -0700 (PDT)
In-Reply-To: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:3c2d:7174:6b35:f873;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:3c2d:7174:6b35:f873
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e56b3504-8fda-4fa0-98a1-ca50d7f4a917n@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: gah4@u.washington.edu (gah4)
Injection-Date: Wed, 18 May 2022 17:53:44 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2087
 by: gah4 - Wed, 18 May 2022 17:53 UTC

On Wednesday, May 18, 2022 at 8:40:00 AM UTC-7, pmk wrote:
> Only one Fortran compiler can cope with this usage -- most crash hard with internal errors -- but I contend that it's conforming usage.

Some years ago, I tried one like this. gfortran didn't like it then,
and (the one I have here) doesn't like it now:

external fun, sub
call trythis(1,sub)
call trythis(2,fun)
stop
end
subroutine sub(i)
print *,'sub',i
return
end
integer function fun(i)
print *,'fun',i
fun=3*i
return
end
subroutine trythis(j, fs)
if(j.eq.1) call fs(5)
if(j.eq.2) k=fs(5)
return
end

If you comment out one of the IF statements, then it is fine.
Note that it never calls a function as a subroutine, or
subroutine as a function, but with both IF statements,
gfortran won't compile it.

Re: CALL FOO when FOO is a function

<jektlsFr6vU1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2259&group=comp.lang.fortran#2259

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: steve@seesignature.invalid (Steve Lionel)
Newsgroups: comp.lang.fortran
Subject: Re: CALL FOO when FOO is a function
Date: Wed, 18 May 2022 14:53:47 -0400
Lines: 14
Message-ID: <jektlsFr6vU1@mid.individual.net>
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
<t6352u$uts$1@newsreader4.netcologne.de>
<a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net c7ftVpeOtKKzBwqQc/tLJghT6DO0pjxixi9avoMCo7ljV10rWd
Cancel-Lock: sha1:l4PWDNczP9fLYVR4DlswgaJI+ZQ=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Content-Language: en-US
In-Reply-To: <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com>
 by: Steve Lionel - Wed, 18 May 2022 18:53 UTC

On 5/18/2022 12:07 PM, pmk wrote:
> Within the body of the function FOO, the name FOO refers to its result variable. The result variable in this case is a procedure pointer to a subroutine. A CALL statement's procedure designator is allowed to be a procedure pointer.

I agree with this.

--
Steve Lionel
ISO/IEC JTC1/SC22/WG5 (Fortran) Convenor
Retired Intel Fortran developer/support
Email: firstname at firstnamelastname dot com
Twitter: @DoctorFortran
LinkedIn: https://www.linkedin.com/in/stevelionel
Blog: https://stevelionel.com/drfortran
WG5: https://wg5-fortran.org

Re: CALL FOO when FOO is a function

<5f35636a-0c76-4a2a-a6f4-371898580e75n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2260&group=comp.lang.fortran#2260

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:6214:27e4:b0:45a:a04d:d835 with SMTP id jt4-20020a05621427e400b0045aa04dd835mr2300305qvb.82.1652920555900;
Wed, 18 May 2022 17:35:55 -0700 (PDT)
X-Received: by 2002:a81:70c3:0:b0:2fe:c68c:aa1d with SMTP id
l186-20020a8170c3000000b002fec68caa1dmr1985132ywc.431.1652920555676; Wed, 18
May 2022 17:35:55 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Wed, 18 May 2022 17:35:55 -0700 (PDT)
In-Reply-To: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=165.225.220.250; posting-account=ZZXq9AoAAAAQEcA7zKAGm0UFQh4gMBv7
NNTP-Posting-Host: 165.225.220.250
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5f35636a-0c76-4a2a-a6f4-371898580e75n@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: parekhvs@gmail.com (FortranFan)
Injection-Date: Thu, 19 May 2022 00:35:55 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2047
 by: FortranFan - Thu, 19 May 2022 00:35 UTC

On Wednesday, May 18, 2022 at 11:40:00 AM UTC-4, pmk wrote:

> Only one Fortran compiler can cope with this usage -- most crash hard with internal errors -- but I contend that it's conforming usage. ..

Yes, that appears correct based on the wording in the standard.

However the relevant wording is not part of any numbered constraint. And the processors then appear to miss out on coping with the semantics in such parts of the standard, especially with features introduced starting with Fortran 90. The "sleeping dogs lie" until an astute reader catches the omission and files support request(s) and the compiler developers find the resources to follow-up on the request(s).

Nonetheless the chances are more compilers can cope with this variant:

function foo() result(r)
procedure(bar), pointer :: r
r => bar
call r
end function

Re: CALL FOO when FOO is a function

<t65iv9$cd0$1@gioia.aioe.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2262&group=comp.lang.fortran#2262

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!aioe.org!ndokQ2QpOQrenJ+3Uzdz+g.user.46.165.242.91.POSTED!not-for-mail
From: juergen.reuter@invalid.com (JRR)
Newsgroups: comp.lang.fortran
Subject: Re: CALL FOO when FOO is a function
Date: Thu, 19 May 2022 16:07:37 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t65iv9$cd0$1@gioia.aioe.org>
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="12704"; posting-host="ndokQ2QpOQrenJ+3Uzdz+g.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.8.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: JRR - Thu, 19 May 2022 14:07 UTC

On 5/18/22 17:39, pmk wrote:
> Only one Fortran compiler can cope with this usage -- most crash hard with internal errors -- but I contend that it's conforming usage.
>
> module m
> contains
> function foo()
> procedure(bar), pointer :: foo
> foo => bar
> call foo ! <-- CALL of a function
> end function
> subroutine bar
> print *, 'in bar'
> end subroutine
> end module
>
> program demo
> use m
> procedure(bar), pointer :: p
> p => foo()
> call p
> end
>

Indeed, the compiler gets confused between the result of the function
foo (which should be the procedure pointer) and the function foo itself.
It works if the result is explicitly specified like by Vipul
(FortranFan), or if the function is defined as recursive. Then gfortran
and Nagfor can compile, Nagfor even the original code with the -f2018
flag (using the Fortran 2018 standard where every function is recursive).

--
Juergen Reuter
Theoretical Particle Physics
Deutsches Elektronen-Synchrotron
Hamburg, Germany
---------------------------------
invalid is desy .and. com is de

Re: CALL FOO when FOO is a function

<0001HW.2836A312030B75557000105DD38F@news.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2263&group=comp.lang.fortran#2263

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: danlnagle@mac.com (Dan Nagle)
Newsgroups: comp.lang.fortran
Subject: Re: CALL FOO when FOO is a function
Date: Thu, 19 May 2022 10:08:50 -0600
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <0001HW.2836A312030B75557000105DD38F@news.eternal-september.org>
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com> <t6352u$uts$1@newsreader4.netcologne.de> <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com> <jektlsFr6vU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="53209f811ef3d96d29b3e9ac6f6125e3";
logging-data="8134"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+39OmMRZ9a0PjQCqbfVb83KkqpUJ4QeyU="
User-Agent: Hogwasher/5.24
Cancel-Lock: sha1:jr23JiYb9pcrjbfEJvrqMYmRwgY=
 by: Dan Nagle - Thu, 19 May 2022 16:08 UTC

Hi,

On May 18, 2022, Steve Lionel wrote
(in article <jektlsFr6vU1@mid.individual.net>):

> On 5/18/2022 12:07 PM, pmk wrote:
> > Within the body of the function FOO, the name FOO refers to its result
> > variable. The result variable in this case is a procedure pointer to a
> > subroutine. A CALL statement's procedure designator is allowed to be a
> > procedure pointer.
>
> I agree with this.

And I'll respectfully disagree.

I think the gremlin lies in the procedure pointer assignment 10.2.2.4.

These are all procedures in the same module so the interfaces are explicit
(as is required by the pointer-ness and the procedure-ness).
Since the interfaces are explicit, agreement is required of the
characteristics.
The characteristics include whether it is a subroutine or a function 15.3.1.
qed

(I'm reading 22-007r1)

--
Cheers!

Dan Nagle

Re: CALL FOO when FOO is a function

<8c2cbb6d-7f18-4cdc-9112-05f3c278d30bn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2264&group=comp.lang.fortran#2264

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:54d:b0:2f3:ce29:234a with SMTP id m13-20020a05622a054d00b002f3ce29234amr4657521qtx.559.1652980633547;
Thu, 19 May 2022 10:17:13 -0700 (PDT)
X-Received: by 2002:a81:1154:0:b0:2fe:d5a4:f26b with SMTP id
81-20020a811154000000b002fed5a4f26bmr6040621ywr.140.1652980633380; Thu, 19
May 2022 10:17:13 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Thu, 19 May 2022 10:17:13 -0700 (PDT)
In-Reply-To: <0001HW.2836A312030B75557000105DD38F@news.eternal-september.org>
Injection-Info: google-groups.googlegroups.com; posting-host=12.154.207.45; posting-account=hzJ1nwoAAACS3IxtuAkjIfQoNdylflgH
NNTP-Posting-Host: 12.154.207.45
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
<t6352u$uts$1@newsreader4.netcologne.de> <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com>
<jektlsFr6vU1@mid.individual.net> <0001HW.2836A312030B75557000105DD38F@news.eternal-september.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8c2cbb6d-7f18-4cdc-9112-05f3c278d30bn@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: pmklausler@gmail.com (pmk)
Injection-Date: Thu, 19 May 2022 17:17:13 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1884
 by: pmk - Thu, 19 May 2022 17:17 UTC

On Thursday, May 19, 2022 at 9:08:54 AM UTC-7, Dan Nagle wrote:
> I think the gremlin lies in the procedure pointer assignment 10.2.2.4.
>
> These are all procedures in the same module so the interfaces are explicit
> (as is required by the pointer-ness and the procedure-ness).
> Since the interfaces are explicit, agreement is required of the
> characteristics.
> The characteristics include whether it is a subroutine or a function 15.3.1.
> qed

The procedure pointer is assigned to the same procedure used to define its interface.

Re: CALL FOO when FOO is a function

<485f8255-124c-4429-9834-da9e9404ae79n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2265&group=comp.lang.fortran#2265

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:6214:238d:b0:461:d89a:e1f3 with SMTP id fw13-20020a056214238d00b00461d89ae1f3mr4905617qvb.118.1652980919567;
Thu, 19 May 2022 10:21:59 -0700 (PDT)
X-Received: by 2002:a81:4e14:0:b0:2ff:2586:ee57 with SMTP id
c20-20020a814e14000000b002ff2586ee57mr5419838ywb.459.1652980918360; Thu, 19
May 2022 10:21:58 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Thu, 19 May 2022 10:21:58 -0700 (PDT)
In-Reply-To: <t65iv9$cd0$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=12.154.207.45; posting-account=hzJ1nwoAAACS3IxtuAkjIfQoNdylflgH
NNTP-Posting-Host: 12.154.207.45
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com> <t65iv9$cd0$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <485f8255-124c-4429-9834-da9e9404ae79n@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: pmklausler@gmail.com (pmk)
Injection-Date: Thu, 19 May 2022 17:21:59 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1585
 by: pmk - Thu, 19 May 2022 17:21 UTC

On Thursday, May 19, 2022 at 7:07:42 AM UTC-7, JRR wrote:
> It works if the result is explicitly specified like by Vipul
> (FortranFan), or if the function is defined as recursive. Then gfortran
> and Nagfor can compile, Nagfor even the original code with the -f2018
> flag (using the Fortran 2018 standard where every function is recursive).

The recursive attribute (defaulted or not) is not relevant to the interpretation of names in a program.

Re: CALL FOO when FOO is a function

<133f7a1c-bff1-49c3-b736-b19da359491an@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2266&group=comp.lang.fortran#2266

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a37:e205:0:b0:6a3:39d1:6292 with SMTP id g5-20020a37e205000000b006a339d16292mr2135092qki.525.1652984783603;
Thu, 19 May 2022 11:26:23 -0700 (PDT)
X-Received: by 2002:a0d:d74a:0:b0:2ff:29ca:1748 with SMTP id
z71-20020a0dd74a000000b002ff29ca1748mr6226673ywd.287.1652984783366; Thu, 19
May 2022 11:26:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!pasdenom.info!usenet-fr.net!fdn.fr!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Thu, 19 May 2022 11:26:23 -0700 (PDT)
In-Reply-To: <0001HW.2836A312030B75557000105DD38F@news.eternal-september.org>
Injection-Info: google-groups.googlegroups.com; posting-host=165.225.220.250; posting-account=ZZXq9AoAAAAQEcA7zKAGm0UFQh4gMBv7
NNTP-Posting-Host: 165.225.220.250
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
<t6352u$uts$1@newsreader4.netcologne.de> <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com>
<jektlsFr6vU1@mid.individual.net> <0001HW.2836A312030B75557000105DD38F@news.eternal-september.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <133f7a1c-bff1-49c3-b736-b19da359491an@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: parekhvs@gmail.com (FortranFan)
Injection-Date: Thu, 19 May 2022 18:26:23 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: FortranFan - Thu, 19 May 2022 18:26 UTC

On Thursday, May 19, 2022 at 12:08:54 PM UTC-4, Dan Nagle wrote:

> ..
> And I'll respectfully disagree.
>
> I think the gremlin lies in the procedure pointer assignment 10.2.2.4.
>
> These are all procedures in the same module so the interfaces are explicit
> (as is required by the pointer-ness and the procedure-ness).
> Since the interfaces are explicit, agreement is required of the
> characteristics.
> The characteristics include whether it is a subroutine or a function 15.3..1.
> qed
>
> (I'm reading 22-007r1) ..

@Dan Nagle,

Are you reading much into OP' s comment in the code in the original post, "CALL of a function"? There is no "call of a function" there, `FOO` is not a function on that line of instruction!

Anyways, the characteristics with the function result which is FOO in the execution-part of the function match with the interface, there are no issues with this.

The only problem here appears to be that several compilers as well as human readers overlook the text of the standard that states, "If RESULT does not appear, the name of the function result is function-name and all occurrences of the function name in execution-part statements in its scope are references to the function result."

Re: CALL FOO when FOO is a function

<50224b08-17fe-4062-9b8c-6252f9a6ac24n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2267&group=comp.lang.fortran#2267

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:6214:238d:b0:461:d89a:e1f3 with SMTP id fw13-20020a056214238d00b00461d89ae1f3mr5149630qvb.118.1652985145291;
Thu, 19 May 2022 11:32:25 -0700 (PDT)
X-Received: by 2002:a25:31c2:0:b0:641:660f:230f with SMTP id
x185-20020a2531c2000000b00641660f230fmr5800175ybx.472.1652985143083; Thu, 19
May 2022 11:32:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Thu, 19 May 2022 11:32:22 -0700 (PDT)
In-Reply-To: <t65iv9$cd0$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=165.225.220.250; posting-account=ZZXq9AoAAAAQEcA7zKAGm0UFQh4gMBv7
NNTP-Posting-Host: 165.225.220.250
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com> <t65iv9$cd0$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <50224b08-17fe-4062-9b8c-6252f9a6ac24n@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: parekhvs@gmail.com (FortranFan)
Injection-Date: Thu, 19 May 2022 18:32:25 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1885
 by: FortranFan - Thu, 19 May 2022 18:32 UTC

On Thursday, May 19, 2022 at 10:07:42 AM UTC-4, JRR wrote:

> .. if the function is defined as recursive. Then gfortran
> and Nagfor can compile, Nagfor even the original code with the -f2018
> flag (using the Fortran 2018 standard where every function is recursive). ..

@Juergen Reuter,

No recursion is involved here, the 2 compilers you have tried might be confused if they are bringing up anything recursion: they both appear to be treating occurrences of `FOO` in the `execution-part` of the function as `function-name`, instead of as function result, the latter being the semantics as stipulated by the standard. Both those compilers will then be non-conforming.

Re: CALL FOO when FOO is a function

<0001HW.2836D11603163E237000033C338F@news.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2268&group=comp.lang.fortran#2268

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: danlnagle@mac.com (Dan Nagle)
Newsgroups: comp.lang.fortran
Subject: Re: CALL FOO when FOO is a function
Date: Thu, 19 May 2022 13:25:10 -0600
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <0001HW.2836D11603163E237000033C338F@news.eternal-september.org>
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com> <t6352u$uts$1@newsreader4.netcologne.de> <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com> <jektlsFr6vU1@mid.individual.net> <0001HW.2836A312030B75557000105DD38F@news.eternal-september.org> <8c2cbb6d-7f18-4cdc-9112-05f3c278d30bn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="53209f811ef3d96d29b3e9ac6f6125e3";
logging-data="15692"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+40tCxpLSMBA0M+JsbstYPuD2BV35RPiY="
User-Agent: Hogwasher/5.24
Cancel-Lock: sha1:sYekGJrty1JIxNR/zTqQjxJDSZM=
 by: Dan Nagle - Thu, 19 May 2022 19:25 UTC

On May 19, 2022, pmk wrote
(in article<8c2cbb6d-7f18-4cdc-9112-05f3c278d30bn@googlegroups.com>):

> On Thursday, May 19, 2022 at 9:08:54 AM UTC-7, Dan Nagle wrote:
> > I think the gremlin lies in the procedure pointer assignment 10.2.2.4.
> >
> > These are all procedures in the same module so the interfaces are explicit
> > (as is required by the pointer-ness and the procedure-ness).
> > Since the interfaces are explicit, agreement is required of the
> > characteristics.
> > The characteristics include whether it is a subroutine or a function 15.3.1.
> > qed
>
> The procedure pointer is assigned to the same procedure used to define its
> interface.

The function statement declares foo to be a function.
The explicit interface for bar declares bar to be a subroutine.
Hence, the mismatch.

--
Cheers!

Dan Nagle

Re: CALL FOO when FOO is a function

<ca164c05-4151-451d-b1d8-df1e91a44967n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2269&group=comp.lang.fortran#2269

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a37:98c4:0:b0:6a0:b47b:2ec6 with SMTP id a187-20020a3798c4000000b006a0b47b2ec6mr4412219qke.730.1652992575892;
Thu, 19 May 2022 13:36:15 -0700 (PDT)
X-Received: by 2002:a25:2383:0:b0:64d:69eb:d6aa with SMTP id
j125-20020a252383000000b0064d69ebd6aamr6355971ybj.499.1652992575638; Thu, 19
May 2022 13:36:15 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Thu, 19 May 2022 13:36:15 -0700 (PDT)
In-Reply-To: <0001HW.2836D11603163E237000033C338F@news.eternal-september.org>
Injection-Info: google-groups.googlegroups.com; posting-host=165.225.220.250; posting-account=ZZXq9AoAAAAQEcA7zKAGm0UFQh4gMBv7
NNTP-Posting-Host: 165.225.220.250
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
<t6352u$uts$1@newsreader4.netcologne.de> <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com>
<jektlsFr6vU1@mid.individual.net> <0001HW.2836A312030B75557000105DD38F@news.eternal-september.org>
<8c2cbb6d-7f18-4cdc-9112-05f3c278d30bn@googlegroups.com> <0001HW.2836D11603163E237000033C338F@news.eternal-september.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ca164c05-4151-451d-b1d8-df1e91a44967n@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: parekhvs@gmail.com (FortranFan)
Injection-Date: Thu, 19 May 2022 20:36:15 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1841
 by: FortranFan - Thu, 19 May 2022 20:36 UTC

On Thursday, May 19, 2022 at 3:25:14 PM UTC-4, Dan Nagle wrote:

> ..
> The function statement declares foo to be a function.
> The explicit interface for bar declares bar to be a subroutine.
> Hence, the mismatch...

That is not the case.

See R1532 and note what is said about function statement versus execution-part and J3/22-007r1, page 336, lines 27 thru' 29.

Re: CALL FOO when FOO is a function

<b62af7de-49fd-420a-89b1-dd43552dd58bn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2270&group=comp.lang.fortran#2270

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:258e:b0:680:f33c:dbcd with SMTP id x14-20020a05620a258e00b00680f33cdbcdmr4709790qko.542.1652996356793;
Thu, 19 May 2022 14:39:16 -0700 (PDT)
X-Received: by 2002:a25:f312:0:b0:64d:6742:1e80 with SMTP id
c18-20020a25f312000000b0064d67421e80mr6610669ybs.273.1652996356579; Thu, 19
May 2022 14:39:16 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Thu, 19 May 2022 14:39:16 -0700 (PDT)
In-Reply-To: <0001HW.2836D11603163E237000033C338F@news.eternal-september.org>
Injection-Info: google-groups.googlegroups.com; posting-host=12.154.207.45; posting-account=hzJ1nwoAAACS3IxtuAkjIfQoNdylflgH
NNTP-Posting-Host: 12.154.207.45
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
<t6352u$uts$1@newsreader4.netcologne.de> <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com>
<jektlsFr6vU1@mid.individual.net> <0001HW.2836A312030B75557000105DD38F@news.eternal-september.org>
<8c2cbb6d-7f18-4cdc-9112-05f3c278d30bn@googlegroups.com> <0001HW.2836D11603163E237000033C338F@news.eternal-september.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b62af7de-49fd-420a-89b1-dd43552dd58bn@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: pmklausler@gmail.com (pmk)
Injection-Date: Thu, 19 May 2022 21:39:16 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1857
 by: pmk - Thu, 19 May 2022 21:39 UTC

On Thursday, May 19, 2022 at 12:25:14 PM UTC-7, Dan Nagle wrote:
> The function statement declares foo to be a function.
> The explicit interface for bar declares bar to be a subroutine.
> Hence, the mismatch.

I think you're saying that a function returning a procedure pointer can only return a pointer to a function, but not a pointer to a subroutine.

That turns out to not be the case.

Re: CALL FOO when FOO is a function

<435127a4-2f66-49e8-9c03-6ca54dd46b4an@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2271&group=comp.lang.fortran#2271

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ad4:4205:0:b0:461:c264:de4f with SMTP id k5-20020ad44205000000b00461c264de4fmr6327242qvp.69.1653007415534;
Thu, 19 May 2022 17:43:35 -0700 (PDT)
X-Received: by 2002:a81:18cc:0:b0:2ff:4211:14a2 with SMTP id
195-20020a8118cc000000b002ff421114a2mr7593227ywy.508.1653007415415; Thu, 19
May 2022 17:43:35 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Thu, 19 May 2022 17:43:35 -0700 (PDT)
In-Reply-To: <0001HW.2836D11603163E237000033C338F@news.eternal-september.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:98e8:ff83:dae1:339d;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:98e8:ff83:dae1:339d
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
<t6352u$uts$1@newsreader4.netcologne.de> <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com>
<jektlsFr6vU1@mid.individual.net> <0001HW.2836A312030B75557000105DD38F@news.eternal-september.org>
<8c2cbb6d-7f18-4cdc-9112-05f3c278d30bn@googlegroups.com> <0001HW.2836D11603163E237000033C338F@news.eternal-september.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <435127a4-2f66-49e8-9c03-6ca54dd46b4an@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: gah4@u.washington.edu (gah4)
Injection-Date: Fri, 20 May 2022 00:43:35 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1907
 by: gah4 - Fri, 20 May 2022 00:43 UTC

On Thursday, May 19, 2022 at 12:25:14 PM UTC-7, Dan Nagle wrote:

(snip)

> The function statement declares foo to be a function.
> The explicit interface for bar declares bar to be a subroutine.
> Hence, the mismatch.

Does that explain why my program doesn't work?

Note that it only calls a function as function, and subroutine as subroutine,
but still it won't compile with gfortran.

Re: CALL FOO when FOO is a function

<957a9000-0050-41f5-8bb4-98ad0f52f083n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2272&group=comp.lang.fortran#2272

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ac8:7d87:0:b0:2f3:edba:a84a with SMTP id c7-20020ac87d87000000b002f3edbaa84amr6327264qtd.186.1653013183216;
Thu, 19 May 2022 19:19:43 -0700 (PDT)
X-Received: by 2002:a81:174b:0:b0:2fe:fad1:2b80 with SMTP id
72-20020a81174b000000b002fefad12b80mr7740258ywx.5.1653013183001; Thu, 19 May
2022 19:19:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Thu, 19 May 2022 19:19:42 -0700 (PDT)
In-Reply-To: <435127a4-2f66-49e8-9c03-6ca54dd46b4an@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=173.49.135.235; posting-account=ZZXq9AoAAAAQEcA7zKAGm0UFQh4gMBv7
NNTP-Posting-Host: 173.49.135.235
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
<t6352u$uts$1@newsreader4.netcologne.de> <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com>
<jektlsFr6vU1@mid.individual.net> <0001HW.2836A312030B75557000105DD38F@news.eternal-september.org>
<8c2cbb6d-7f18-4cdc-9112-05f3c278d30bn@googlegroups.com> <0001HW.2836D11603163E237000033C338F@news.eternal-september.org>
<435127a4-2f66-49e8-9c03-6ca54dd46b4an@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <957a9000-0050-41f5-8bb4-98ad0f52f083n@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: parekhvs@gmail.com (FortranFan)
Injection-Date: Fri, 20 May 2022 02:19:43 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2905
 by: FortranFan - Fri, 20 May 2022 02:19 UTC

On Thursday, May 19, 2022 at 8:43:37 PM UTC-4, gah4 wrote:

@gah4,

>
> Does that explain why my program doesn't work?

No, your code has genuine mismatch in the scope of your `trythis` subprogram.

> but still it won't compile with gfortran.

If you have a Fortran 2018 compiler, here's a variant of your code the processor should accept: with "gfortran", you can replace the "generic" statement with an INTERFACE block.

module m
generic :: trythis => trythis1, trythis2
contains
subroutine trythis1(fs)
procedure(sub) :: fs
call fs(5)
end subroutine
subroutine trythis2(fs)
procedure(fun) :: fs
print *, "fs returns: ", fs(5)
end subroutine
subroutine sub(i)
print *,'sub',i
return
end
integer function fun(i)
print *,'fun',i
fun=3*i
return
end
end module
use m
call trythis(sub)
call trythis(fun)
end

--- console output ---
C:\temp>ifort /standard-semantics p.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.5.0 Build 20211109_000000
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.

Microsoft (R) Incremental Linker Version 14.31.31105.0
Copyright (C) Microsoft Corporation. All rights reserved.

-out:p.exe
-subsystem:console
p.obj

C:\temp>p.exe
sub 5
fun 5
15

Re: CALL FOO when FOO is a function

<84685be8-ff9f-414a-a9d4-68e7a490e6a6n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2273&group=comp.lang.fortran#2273

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ac8:5a15:0:b0:2f3:d052:216a with SMTP id n21-20020ac85a15000000b002f3d052216amr6255301qta.597.1653014795298;
Thu, 19 May 2022 19:46:35 -0700 (PDT)
X-Received: by 2002:a05:6902:110c:b0:634:62c4:ab7e with SMTP id
o12-20020a056902110c00b0063462c4ab7emr7878104ybu.539.1653014795123; Thu, 19
May 2022 19:46:35 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Thu, 19 May 2022 19:46:34 -0700 (PDT)
In-Reply-To: <957a9000-0050-41f5-8bb4-98ad0f52f083n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:98e8:ff83:dae1:339d;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:98e8:ff83:dae1:339d
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
<t6352u$uts$1@newsreader4.netcologne.de> <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com>
<jektlsFr6vU1@mid.individual.net> <0001HW.2836A312030B75557000105DD38F@news.eternal-september.org>
<8c2cbb6d-7f18-4cdc-9112-05f3c278d30bn@googlegroups.com> <0001HW.2836D11603163E237000033C338F@news.eternal-september.org>
<435127a4-2f66-49e8-9c03-6ca54dd46b4an@googlegroups.com> <957a9000-0050-41f5-8bb4-98ad0f52f083n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <84685be8-ff9f-414a-a9d4-68e7a490e6a6n@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: gah4@u.washington.edu (gah4)
Injection-Date: Fri, 20 May 2022 02:46:35 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2701
 by: gah4 - Fri, 20 May 2022 02:46 UTC

On Thursday, May 19, 2022 at 7:19:44 PM UTC-7, FortranFan wrote:

(snip, I wrote)

> > Does that explain why my program doesn't work?

> No, your code has genuine mismatch in the scope of your `trythis` subprogram.
> > but still it won't compile with gfortran.

> If you have a Fortran 2018 compiler, here's a variant of your code the processor
> should accept: with "gfortran", you can replace the "generic" statement with an INTERFACE block.

I actually wrote a program like this some years ago, when a similar question
came up. I then had to recreate it. As far as I know, it uses only Fortran 66
features, but the only compiler I tried it on was gfortran.

Much of Fortran 66 trusts users to do things right, such as argument
type matching. Even so, as far as I know, Fortran 66 doesn't have a
different type for subroutine names and function names.

But okay, the way you write it sub and fun have to be in the module,
which is less convenient than it could be. It is especially inconvenient
if you want to separately compile each of them.

Re: CALL FOO when FOO is a function

<0001HW.2837F298035A17F57000089F738F@news.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2274&group=comp.lang.fortran#2274

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: danlnagle@mac.com (Dan Nagle)
Newsgroups: comp.lang.fortran
Subject: Re: CALL FOO when FOO is a function
Date: Fri, 20 May 2022 10:00:24 -0600
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <0001HW.2837F298035A17F57000089F738F@news.eternal-september.org>
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com> <t6352u$uts$1@newsreader4.netcologne.de> <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com> <jektlsFr6vU1@mid.individual.net> <0001HW.2836A312030B75557000105DD38F@news.eternal-september.org> <8c2cbb6d-7f18-4cdc-9112-05f3c278d30bn@googlegroups.com> <0001HW.2836D11603163E237000033C338F@news.eternal-september.org> <ca164c05-4151-451d-b1d8-df1e91a44967n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="1d953f2d8b431ba74fe606a6e1f904f9";
logging-data="2645"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19rcCd+Jf1wVE+E4jZ3LBkuxFWIXdfbAZI="
User-Agent: Hogwasher/5.24
Cancel-Lock: sha1:iPsv+CWkrOuTWrdSRlBEq6hVKpI=
 by: Dan Nagle - Fri, 20 May 2022 16:00 UTC

On May 19, 2022, FortranFan wrote
(in article<ca164c05-4151-451d-b1d8-df1e91a44967n@googlegroups.com>):

> On Thursday, May 19, 2022 at 3:25:14 PM UTC-4, Dan Nagle wrote:
>
> > ..
> > The function statement declares foo to be a function.
> > The explicit interface for bar declares bar to be a subroutine.
> > Hence, the mismatch...
>
> That is not the case.
>
> See R1532 and note what is said about function statement versus
> execution-part and J3/22-007r1, page 336, lines 27 thru' 29.

And at line 25 the function result variable has all the characteristics of
the function.

--
Cheers!

Dan Nagle

Re: CALL FOO when FOO is a function

<0001HW.2837F3DD035A643D7000089F738F@news.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2275&group=comp.lang.fortran#2275

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: danlnagle@mac.com (Dan Nagle)
Newsgroups: comp.lang.fortran
Subject: Re: CALL FOO when FOO is a function
Date: Fri, 20 May 2022 10:05:49 -0600
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <0001HW.2837F3DD035A643D7000089F738F@news.eternal-september.org>
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com> <t6352u$uts$1@newsreader4.netcologne.de> <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com> <jektlsFr6vU1@mid.individual.net> <0001HW.2836A312030B75557000105DD38F@news.eternal-september.org> <8c2cbb6d-7f18-4cdc-9112-05f3c278d30bn@googlegroups.com> <0001HW.2836D11603163E237000033C338F@news.eternal-september.org> <b62af7de-49fd-420a-89b1-dd43552dd58bn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="1d953f2d8b431ba74fe606a6e1f904f9";
logging-data="2645"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199Rd90SrQvvxgyRt38ZTibOESZcfRlymM="
User-Agent: Hogwasher/5.24
Cancel-Lock: sha1:7MduBNYEt8/ZAi9tsuKLuL/NMew=
 by: Dan Nagle - Fri, 20 May 2022 16:05 UTC

Hi,

On May 19, 2022, pmk wrote
(in article<b62af7de-49fd-420a-89b1-dd43552dd58bn@googlegroups.com>):

> On Thursday, May 19, 2022 at 12:25:14 PM UTC-7, Dan Nagle wrote:
> > The function statement declares foo to be a function.
> > The explicit interface for bar declares bar to be a subroutine.
> > Hence, the mismatch.
>
> I think you're saying that a function returning a procedure pointer can only
> return a pointer to a function, but not a pointer to a subroutine.
>
> That turns out to not be the case.

If you write a result-name in foo,
and you use a local variable with the subroutine characteristic in bar.

--
Cheers!

Dan Nagle

Re: CALL FOO when FOO is a function

<46eb9bc5-af40-43fe-acef-1f1dd29556adn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2276&group=comp.lang.fortran#2276

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ac8:5b50:0:b0:2f3:f4a7:d6cb with SMTP id n16-20020ac85b50000000b002f3f4a7d6cbmr8578959qtw.287.1653067671044;
Fri, 20 May 2022 10:27:51 -0700 (PDT)
X-Received: by 2002:a25:8244:0:b0:64d:c355:4b75 with SMTP id
d4-20020a258244000000b0064dc3554b75mr10651167ybn.386.1653067670798; Fri, 20
May 2022 10:27:50 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Fri, 20 May 2022 10:27:50 -0700 (PDT)
In-Reply-To: <0001HW.2837F298035A17F57000089F738F@news.eternal-september.org>
Injection-Info: google-groups.googlegroups.com; posting-host=165.225.220.250; posting-account=ZZXq9AoAAAAQEcA7zKAGm0UFQh4gMBv7
NNTP-Posting-Host: 165.225.220.250
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
<t6352u$uts$1@newsreader4.netcologne.de> <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com>
<jektlsFr6vU1@mid.individual.net> <0001HW.2836A312030B75557000105DD38F@news.eternal-september.org>
<8c2cbb6d-7f18-4cdc-9112-05f3c278d30bn@googlegroups.com> <0001HW.2836D11603163E237000033C338F@news.eternal-september.org>
<ca164c05-4151-451d-b1d8-df1e91a44967n@googlegroups.com> <0001HW.2837F298035A17F57000089F738F@news.eternal-september.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <46eb9bc5-af40-43fe-acef-1f1dd29556adn@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: parekhvs@gmail.com (FortranFan)
Injection-Date: Fri, 20 May 2022 17:27:51 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3443
 by: FortranFan - Fri, 20 May 2022 17:27 UTC

On Friday, May 20, 2022 at 12:00:28 PM UTC-4, Dan Nagle wrote:
> ..
> And at line 25 the function result variable has all the characteristics of
> the function. ..
and
On Friday, May 20, 2022 at 12:05:53 PM UTC-4, Dan Nagle wrote:
> ..
> If you write a result-name in foo,
> and you use a local variable with the subroutine characteristic in bar.

@Dan Nagle,

I fail to see how your first point, "the function result variable has all the characteristics of the function" of any relevance to the original post. A function can *indeed* have a function-result that is a procedure pointer to a subroutine, there are no doubts it. The following is a conforming program:

module m
contains
function foo() result(r)
procedure(bar), pointer :: r
r => bar
end function
subroutine bar
print *, 'in bar'
end subroutine
end module

The question implied by OP is
1. If RESULT clause does NOT appear and
2. There is a reference to the function-name in the execution-part of the function,
what does the standard and the compilers have to "say" about that?

Well with the code in the original post, it conforms.

The compilers appear to "fall over" at the line "CALL foo" only because the function-name itself is FOO.

But the standard makes it clear, "If RESULT does not appear, the name of the function result is function-name and all occurrences of the function name in execution-part statements in its scope are references to the function result."

Thus "CALL foo" does not involved a reference to the function-name per the standard, instead it is a reference to a procedure pointer associated with `bar`. One can see it as though the "offending" line were `CALL bar` and there is nothing non-conformant when viewed as such.

Re: CALL FOO when FOO is a function

<badf714a-0224-404d-8c62-353679c56116n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2277&group=comp.lang.fortran#2277

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:6214:2b09:b0:45b:59b:5df6 with SMTP id jx9-20020a0562142b0900b0045b059b5df6mr10797763qvb.22.1653126964081;
Sat, 21 May 2022 02:56:04 -0700 (PDT)
X-Received: by 2002:a81:174b:0:b0:2fe:fad1:2b80 with SMTP id
72-20020a81174b000000b002fefad12b80mr13933066ywx.5.1653126963943; Sat, 21 May
2022 02:56:03 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.fortran
Date: Sat, 21 May 2022 02:56:03 -0700 (PDT)
In-Reply-To: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=202.67.103.232; posting-account=S_MdrwoAAAD7T2pxG2e393dk6y0tc0Le
NNTP-Posting-Host: 202.67.103.232
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <badf714a-0224-404d-8c62-353679c56116n@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: robin.vowels@gmail.com (Robin Vowels)
Injection-Date: Sat, 21 May 2022 09:56:04 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1794
 by: Robin Vowels - Sat, 21 May 2022 09:56 UTC

On Thursday, May 19, 2022 at 1:40:00 AM UTC+10, pmk wrote:
> Only one Fortran compiler can cope with this usage -- most crash hard with internal errors -- but I contend that it's conforming usage.
>
> module m
> contains
> function foo()
> procedure(bar), pointer :: foo
> foo => bar
> call foo ! <-- CALL of a function
> end function
> subroutine bar
> print *, 'in bar'
> end subroutine
> end module
>
> program demo
> use m
> procedure(bar), pointer :: p
> p => foo()
> call p
> end
..
Why do you want to do this?
..
Just CALL a subroutine, and invoke a function with a function reference,
in the traditional way.

Re: CALL FOO when FOO is a function

<0001HW.28393C2E0028507570000EA3538F@news.eternal-september.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2278&group=comp.lang.fortran#2278

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: danlnagle@mac.com (Dan Nagle)
Newsgroups: comp.lang.fortran
Subject: Re: CALL FOO when FOO is a function
Date: Sat, 21 May 2022 09:26:38 -0600
Organization: A noiseless patient Spider
Lines: 125
Message-ID: <0001HW.28393C2E0028507570000EA3538F@news.eternal-september.org>
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com> <t6352u$uts$1@newsreader4.netcologne.de> <a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com> <jektlsFr6vU1@mid.individual.net> <0001HW.2836A312030B75557000105DD38F@news.eternal-september.org> <8c2cbb6d-7f18-4cdc-9112-05f3c278d30bn@googlegroups.com> <0001HW.2836D11603163E237000033C338F@news.eternal-september.org> <ca164c05-4151-451d-b1d8-df1e91a44967n@googlegroups.com> <0001HW.2837F298035A17F57000089F738F@news.eternal-september.org> <46eb9bc5-af40-43fe-acef-1f1dd29556adn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="ced13e85d842a7b38d9bc4da61195c46";
logging-data="24101"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YH5Fr8+N84iz+NV5mDD9CP8RZYf7n2Qk="
User-Agent: Hogwasher/5.24
Cancel-Lock: sha1:k5xLCWZxGcN52+S6tXJOfmZNxTs=
 by: Dan Nagle - Sat, 21 May 2022 15:26 UTC

Hi,

On May 20, 2022, FortranFan wrote
(in article<46eb9bc5-af40-43fe-acef-1f1dd29556adn@googlegroups.com>):

> On Friday, May 20, 2022 at 12:00:28 PM UTC-4, Dan Nagle wrote:
> > ..
> > And at line 25 the function result variable has all the characteristics of
> > the function. ..
> and
> On Friday, May 20, 2022 at 12:05:53 PM UTC-4, Dan Nagle wrote:
> > ..
> > If you write a result-name in foo,
> > and you use a local variable with the subroutine characteristic in bar.
>
> @Dan Nagle,
>
> I fail to see how your first point, "the function result variable has all the
> characteristics of the function" of any relevance to the original post.

The relevance is that, once the function statement gives the name foo the
function characteristic,
the declaration of the local result variable cannot change it. The
declaration can set other
attributes, but cannot change whether a name refers to an entity that is a
function or a subroutine.
That is determined by whether the name appears in a function statement
or a subroutine statement.

> A
> function can *indeed* have a function-result that is a procedure pointer to a
> subroutine, there are no doubts it. The following is a conforming program:
>
> module m
> contains
> function foo() result(r)
> procedure(bar), pointer :: r
> r => bar
> end function
> subroutine bar
> print *, 'in bar'
> end subroutine
> end module

I agree that this is conforming code.
But that is due to the use of a result variable with a different name.
This allows declaration of the function characteristics separately
from the result value characteristics.

That is, the above code never tells me that foo is a function and a
subroutine.

>
>
> The question implied by OP is
> 1. If RESULT clause does NOT appear and
> 2. There is a reference to the function-name in the execution-part of the
> function,
> what does the standard and the compilers have to "say" about that?

It says the result variable has all the characteristics of the function name,
and that whether something is a function or a subroutine is a characteristic.

>
>
> Well with the code in the original post, it conforms.

It does not. The original code confuses whether foo is a function or a
subroutine.
This it cannot do and be standard-conforming.

I believe that another local variable is needed where foo is called,
again to separate the function (value-producing) aspect from the subroutine
aspect
(target of pointer).

>
>
> The compilers appear to "fall over" at the line "CALL foo" only because the
> function-name itself is FOO.

And the compiler can't guess whether you mean foo is a function or a
subroutine.
There are contradictory declarations.

>
>
> But the standard makes it clear, "If RESULT does not appear, the name of the
> function result is function-name and all occurrences of the function name in
> execution-part statements in its scope are references to the function result."

Can you read the paragraph just before the above?
You cannot specify the type of a function both on the function statement
and within the function. Yet that is what you want to do.

You must separate the declaration of the function from the declaration
of the function's value. Do this by using another name, as in your result
example
(which I agree is conforming).

"
>
>
> Thus "CALL foo" does not involved a reference to the function-name per the
> standard, instead it is a reference to a procedure pointer associated with
> `bar`. One can see it as though the "offending" line were `CALL bar` and
> there is nothing non-conformant when viewed as such.

Not so. C1525 disagrees. The name appearing in a call statement must
designate
a subroutine. foo is the name of a function (whose value is a pointer to
subroutine).

Again, this can be cured by using a local variable to hold the value
returned from the function foo, the which can then be called.

The theme is that one must distinguish the function-ness of foo
from the subroutine-ness of foo's result value. An extra variable does the
trick.

--
Cheers!

Dan Nagle

Re: CALL FOO when FOO is a function

<_n9iK.4090$Dr6.3622@fx06.iad>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=2279&group=comp.lang.fortran#2279

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx06.iad.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:91.0)
Gecko/20100101 Thunderbird/91.9.0
Subject: Re: CALL FOO when FOO is a function
Content-Language: en-US
Newsgroups: comp.lang.fortran
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
<t6352u$uts$1@newsreader4.netcologne.de>
<a0bd901c-521a-4367-8df5-d98b8b1ca2a6n@googlegroups.com>
<jektlsFr6vU1@mid.individual.net>
<0001HW.2836A312030B75557000105DD38F@news.eternal-september.org>
<8c2cbb6d-7f18-4cdc-9112-05f3c278d30bn@googlegroups.com>
<0001HW.2836D11603163E237000033C338F@news.eternal-september.org>
<ca164c05-4151-451d-b1d8-df1e91a44967n@googlegroups.com>
<0001HW.2837F298035A17F57000089F738F@news.eternal-september.org>
<46eb9bc5-af40-43fe-acef-1f1dd29556adn@googlegroups.com>
<0001HW.28393C2E0028507570000EA3538F@news.eternal-september.org>
From: nospam@nowhere.org (Ron Shepard)
In-Reply-To: <0001HW.28393C2E0028507570000EA3538F@news.eternal-september.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 83
Message-ID: <_n9iK.4090$Dr6.3622@fx06.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sat, 21 May 2022 12:33:45 -0500
X-Received-Bytes: 5228
 by: Ron Shepard - Sat, 21 May 2022 17:33 UTC

On 5/21/22 10:26 AM, Dan Nagle wrote:
[...]
>> Thus "CALL foo" does not involved a reference to the function-name per the
>> standard, instead it is a reference to a procedure pointer associated with
>> `bar`. One can see it as though the "offending" line were `CALL bar` and
>> there is nothing non-conformant when viewed as such.
>
> Not so. C1525 disagrees. The name appearing in a call statement must
> designate
> a subroutine.

In that call statement, foo is a procedure pointer to a subroutine, so
does that not qualify as designating a subroutine?

> foo is the name of a function (whose value is a pointer to
> subroutine).

Without the result() clause, foo is the value of the function within the
function body, which is a pointer to a procedure. A procedure pointer
can point to either subroutines or functions, without restriction. There
are not separate pointers for functions and for subroutines, they all
share the same type declaration.

Furthermore, after the pointer assignment, it would be illegal to
reference foo as a function within the body of the function. It is
REQUIRED to reference it only as a subroutine and with the interface
that is consistent with that of the target subroutine.

>
> Again, this can be cured by using a local variable to hold the value
> returned from the function foo, the which can then be called.

The result() clause was added to the language in order to allow direct
recursion to the function from within the body of the function. Of
course, the recursive attribute is required, either explicitly (f90) or
implicitly (f2003), in this case. After result(r) is added, then any
references to foo are to the function, while references to r are to the
value. It is even allowed to do indirect recursion without the result()
clause, it is only direct recursion from foo to itself that requires the
result() clause. However, in this example, there is no recursion
involved anywhere, direct nor indirect. If recursion is not involved
then it seems like result() should not be necessary.

Without result(), there is no ambiguity that within the body of the
function that references to foo are references to the value.

>
> The theme is that one must distinguish the function-ness of foo
> from the subroutine-ness of foo's result value. An extra variable does the
> trick.

Those two "-ness" are already distinguished. Without the result(), all
references to foo within the body are to its value. With the result()
clause, all references to foo are recursive references to the function
itself. It follows that since no recursive references to foo are
invoked, then result() is unnecessary. It is like declaring a variable
and then not referencing it. Of course, in this case, that might not be
a bad idea for human readers of the code, but it seems unnecessary for
the compiler which knows all of this because there is no ambiguity in
the language in this respect.

There is also the question of the argument list. If foo() and/or bar()
had arguments, then all references to the foo function would require
that argument list while references to the procedure pointer value would
require the absence of an argument list. The associated code would then
look like

! no result() code
foo => bar ! no argument list.
call bar(arg1,...) ! with argument list
call foo(arg1,...) ! with argument list, through the pointer value.

! with result(r)
r => bar ! no argument list.
x=....foo(arg1,...) ! expression with direct recursion to foo()
call bar(arg1,...) ! with argument list.
call r(arg1,...) ! with argument list, through the pointer value.

$.02 -Ron Shepard

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor