Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"God is a comedian playing to an audience too afraid to laugh." -- Voltaire


devel / comp.lang.fortran / Re: 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
Re: CALL FOO when FOO is a function

<4d29c649-6c51-489c-962b-15b73e342f05n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:6214:c29:b0:45a:fedd:7315 with SMTP id a9-20020a0562140c2900b0045afedd7315mr12299346qvd.59.1653173361916;
Sat, 21 May 2022 15:49:21 -0700 (PDT)
X-Received: by 2002:a25:2383:0:b0:64d:69eb:d6aa with SMTP id
j125-20020a252383000000b0064d69ebd6aamr15761591ybj.499.1653173361704; Sat, 21
May 2022 15:49:21 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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 15:49:21 -0700 (PDT)
In-Reply-To: <0001HW.28393C2E0028507570000EA3538F@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>
<46eb9bc5-af40-43fe-acef-1f1dd29556adn@googlegroups.com> <0001HW.28393C2E0028507570000EA3538F@news.eternal-september.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4d29c649-6c51-489c-962b-15b73e342f05n@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: parekhvs@gmail.com (FortranFan)
Injection-Date: Sat, 21 May 2022 22:49:21 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3172
 by: FortranFan - Sat, 21 May 2022 22:49 UTC

On Saturday, May 21, 2022 at 11:26:43 AM UTC-4, Dan Nagle wrote:

> ..
> 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.

@Dan Nagle,

Re: your comment "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,"

* are you saying a function statement `foo` prevents the name `foo` from it from being treated as a function result variable that is a procedure pointer to a subroutine whereas it can have other characteristics?

The following is a conforming program per my read of the Fortran 90 standard, chances are rather high every Fortran 90 and later compiler you can try will process the program ok:

print *, foo(1)
contains
function foo(a)
integer, intent(in) :: a
integer :: foo(2)
foo(1) = a
foo(2) = foo(1) + 1
end function
end

Do you think in this case once the function statement gives the name foo the function characteristic, the declaration of the local result variable cannot change it to an array of rank-1?

Re: CALL FOO when FOO is a function

<0001HW.283A8CCC007734B470000210D38F@news.eternal-september.org>

  copy mid

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

  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: Sun, 22 May 2022 09:22:52 -0600
Organization: A noiseless patient Spider
Lines: 135
Message-ID: <0001HW.283A8CCC007734B470000210D38F@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> <0001HW.28393C2E0028507570000EA3538F@news.eternal-september.org> <_n9iK.4090$Dr6.3622@fx06.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="6b6711a857e9950ef86973a4b7f02b32";
logging-data="28915"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+h3/S/2xla/P7qG7mvGKWJjq27FGbk8rg="
User-Agent: Hogwasher/5.24
Cancel-Lock: sha1:jM6Zj4xl9yXfAKU/GPULXhf5J0M=
 by: Dan Nagle - Sun, 22 May 2022 15:22 UTC

Hi,

You can't change a characteristic with a type statement. Full stop.
You can create a characteristic with a type statement, but you cannot
change an existing characteristic.

On May 21, 2022, Ron Shepard wrote
(in article <_n9iK.4090$Dr6.3622@fx06.iad>):

> 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?

No. The name foo appears in a function statement,
which makes it a function.

The value of foo is a pointer to subroutine.
But foo is a function.

>
>
> > 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.

The use must be consistent with the declarations of pointer and target.
For example, the use must be consistent with the interface.

>
>
> 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.

The function result variable inherits all the characteristics
of the function name.

The statement declaring foo to be a pointer to subroutine
is invalid because it attempts to change the characteristics of foo.

The function statement declares two characteristics of foo:
1. foo is a function, and
2. foo has no arguments.

Neither can be contradicted and be standard-conforming.

(aside- this is real nitpicking)

In the above paragraph, shouldn't the prohibition on foo-as-function
start with the declaration of foo-as-pointer-to-subroutine?
So how do you assign a value at all?
What is the function result variable of a subroutine?

(end aside)

>
>
> >
> > 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.

result was also added to allow the function value to be an array.
(This is one reason why result variables inherit all characteristics
of the function name- you want the array to have the correct shape.)

>
>
> 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.

The ambiguity is that you want some references to foo to be a function,
and some references to foo to be a subroutine.

Whether foo is a function or a subroutine is a characteristic
that cannot change.

foo is a function because it is the name in a function statement.
The type of foo is irrelevant.

foo is not a subroutine because its name does not appear in a subroutine
statement.
Attempting to do so by setting the type of the result is not conforming.

<snip>

>
> $.02 -Ron Shepard

--
Cheers!

Dan Nagle

Re: CALL FOO when FOO is a function

<CYuiK.16679$wIO9.3518@fx12.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx12.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>
<_n9iK.4090$Dr6.3622@fx06.iad>
<0001HW.283A8CCC007734B470000210D38F@news.eternal-september.org>
From: nospam@nowhere.org (Ron Shepard)
In-Reply-To: <0001HW.283A8CCC007734B470000210D38F@news.eternal-september.org>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 123
Message-ID: <CYuiK.16679$wIO9.3518@fx12.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: Sun, 22 May 2022 13:06:26 -0500
X-Received-Bytes: 6443
 by: Ron Shepard - Sun, 22 May 2022 18:06 UTC

On 5/22/22 10:22 AM, Dan Nagle wrote:
[...]
> The function result variable inherits all the characteristics
> of the function name.

Your claim would seem to apply to both cases, with and without the
result() clause. Yet you have already stated that it doesn't, that it
only applies to the case without the result() clause.

Or are you claiming that with result(r), the entity r is not the result
variable? Or that the entity r does not inherit all the characteristics
of foo, the function name.

Either way, it seems like a contradiction to the above statement?

>
> The statement declaring foo to be a pointer to subroutine
> is invalid because it attempts to change the characteristics of foo.

Yet, with the result() clause you claim that the same thing is allowed.
Isn't this inconsistent with your above argument?

>
> The function statement declares two characteristics of foo:
> 1. foo is a function, and
> 2. foo has no arguments.

Within the body of the function, and without the result() clause,
references to foo are to the result value, not recursive references to
the function. This is the same as if it were say, an integer function.
References within the body would be to the integer value, not recursive
references to the function with no arguments. Here is another example of
this, which I think is conforming:

program func
write(*,*) foo(3)
contains
function foo(n)
integer :: foo(2) ! return an integer array.
integer, intent(in) :: n
foo(1) = -n
foo(2) = n
return
end function foo
end program func

Note that there is no result() clause. The result of the function is an
integer array, so result() is not necessary simply to declare an array
valued function. Also, within the function body, the references to
foo(1) and foo(2) are to the elements of the integer array, they are not
recursive references to the function with its single integer argument.

Is this small program conforming?

[...]
> result was also added to allow the function value to be an array.

The example above shows that result() is not required for this purpose.

> (This is one reason why result variables inherit all characteristics
> of the function name- you want the array to have the correct shape.)

See the above example which contradicts this statement.

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

This is demonstrated with the above example. There is no result()
clause, and there is no ambiguity, even though foo(1) looks the same
with either interpretation.

>>> 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.

This is demonstrated with the above code for the case of an integer
array. The language already distinguishes between foo(1) as a recursive
function reference and foo(1) as an array reference. The same occurs for
other types, including I believe procedure pointers.

> The ambiguity is that you want some references to foo to be a function,
> and some references to foo to be a subroutine.

There is no ambiguity. Without the result() clause, all references to
foo within the function body are to its value as an integer array in the
above example, and to a procedure pointer in the example being discussed.

>
> Whether foo is a function or a subroutine is a characteristic
> that cannot change.

foo is a function, and its value is a procedure pointer.

> foo is a function because it is the name in a function statement.
> The type of foo is irrelevant.

This statement is not consistent with the above example. There foo is a
function, and the type of its value is an integer array. References such
as foo(1) within the body of the function are to the integer array, not
recursive references to the function.

> foo is not a subroutine because its name does not appear in a subroutine
> statement.
> Attempting to do so by setting the type of the result is not conforming.

Are you claiming that the value of foo cannot be a procedure pointer
that is assigned to a subroutine either with or without the result() clause?

I remember Richard Maine saying that one should never write a function
that returns a pointer value. I'm not sure this is what he had in mind,
but perhaps this discussion reflects the wisdom of his warning.

However, having said that, if I were to write a function that returns a
procedure pointer, I would always use the result() clause to make it
easier for a human to understand, although I think the language is
unambiguous in either the result() or the no result() case.

$.02 -Ron Shepard

Re: CALL FOO when FOO is a function

<t6e0ac$1rcrn$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED.2601:282:1a81:9bc0:2025:63e6:ccf:69!not-for-mail
From: not_valid@comcast.net (James Van Buskirk)
Newsgroups: comp.lang.fortran
Subject: Re: CALL FOO when FOO is a function
Date: Sun, 22 May 2022 12:44:09 -0600
Organization: A noiseless patient Spider
Lines: 2
Message-ID: <t6e0ac$1rcrn$1@dont-email.me>
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> <_n9iK.4090$Dr6.3622@fx06.iad> <0001HW.283A8CCC007734B470000210D38F@news.eternal-september.org> <CYuiK.16679$wIO9.3518@fx12.iad>
MIME-Version: 1.0
Content-Type: text/plain;
format=flowed;
charset="UTF-8";
reply-type=response
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 22 May 2022 18:44:28 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="2601:282:1a81:9bc0:2025:63e6:ccf:69";
logging-data="1946487"; mail-complaints-to="abuse@eternal-september.org"
In-Reply-To: <CYuiK.16679$wIO9.3518@fx12.iad>
Importance: Normal
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3528.331
X-Priority: 3
X-Newsreader: Microsoft Windows Live Mail 16.4.3528.331
 by: James Van Buskirk - Sun, 22 May 2022 18:44 UTC

"Ron Shepard" wrote in message news:CYuiK.16679$wIO9.3518@fx12.iad...

> Within the body of the function, and without the result() clause,
> references to foo are to the result value, not recursive references to
> the function. This is the same as if it were say, an integer function.
> References within the body would be to the integer value, not recursive
> references to the function with no arguments. Here is another example of
> this, which I think is conforming:

> program func
> write(*,*) foo(3)
> contains
> function foo(n)
> integer :: foo(2) ! return an integer array.
> integer, intent(in) :: n
> foo(1) = -n
> foo(2) = n
> return
> end function foo
> end program func

> Note that there is no result() clause. The result of the function is an
> integer array, so result() is not necessary simply to declare an array
> valued function. Also, within the function body, the references to
> foo(1) and foo(2) are to the elements of the integer array, they are not
> recursive references to the function with its single integer argument.

This was an issue that Steve Lionel was certainly familiar with because
the Digital compiler had an extension that allowed for recursive
functions. When the standard itself expanded to allow recursive
procedures one could create standard-conforming programs where
the Digital extension led to a result inconsistent with what the
standard dictates, and the above example might be one such.

Of course, Digital had to follow the standard but yet not require
its user base to throw out all of their code at the same time. It's
kind of mind-bending to think about the function foo and the
result variable foo as different things with the same name in
the seminal example of this thread, but different things can indeed
have the same name. If you google my name the first thing it comes
up with is some pervert from the West Coast. Another thing about
names with which we are all familiar:
https://en.wikipedia.org/wiki/Haddocks%27_Eyes

I note that the title of this thread is intentionally provocative. If
it were something like "CALL the target of FOO when FOO is a
result variable that is a pointer to a subroutine" the thread would
not have been nearly as entertaining.

Re: CALL FOO when FOO is a function

<t6eqqp$p64$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: cyrmag7@gmail.com (Cyrmag)
Newsgroups: comp.lang.fortran
Subject: Re: CALL FOO when FOO is a function
Date: Sun, 22 May 2022 21:16:55 -0500
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <t6eqqp$p64$1@dont-email.me>
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>
<_n9iK.4090$Dr6.3622@fx06.iad>
<0001HW.283A8CCC007734B470000210D38F@news.eternal-september.org>
<CYuiK.16679$wIO9.3518@fx12.iad> <t6e0ac$1rcrn$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 23 May 2022 02:16:57 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="afc29687d19aa302beb94bd7c9c60b43";
logging-data="25796"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+lgkbdkkjep9G808o3GqgU"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
Cancel-Lock: sha1:kGL0ImYfRqI80YeXl6pH5zUYW0Q=
In-Reply-To: <t6e0ac$1rcrn$1@dont-email.me>
Content-Language: en-US
 by: Cyrmag - Mon, 23 May 2022 02:16 UTC

On 5/22/2022 1:44 PM, James Van Buskirk wrote:
<--SNIP-->

> It's kind of mind-bending to think about the function foo and the
> result variable foo as different things with the same name in
> the seminal example of this thread, but different things can indeed
> have the same name. If you google my name the first thing it comes
> up with is some pervert from the West Coast. Another thing about
> names with which we are all familiar:
> https://en.wikipedia.org/wiki/Haddocks%27_Eyes
>
Not only the same name, as James writes, but sometimes we use the same
notation but with different meanings.

Indeed, having multiple purposes/meanings of parentheses -- to hold a
sequence of subprogram arguments, and also to hold subscripts -- is the
cause of so many complicated and confusing rules. Had we used the
notation of other programming languages, "foo(n)" would be a function
invocation and "foo[n]" would be the n-th or (n+1)th element of array
"foo". As things stand in Fortran, we are burdened with mind-bending
stuff such as the following in F2008:

"If RESULT appears, the name of the result variable of the function is
result-name and all occurrences of the function name in execution-part
statements in its scope refer to the function itself. If RESULT does not
appear, the name of the result variable is function-name and all
occurrences of the function name in execution-part statements in its
scope are references to the result variable."

One could comically restate this quotation as "If RESULT appears, the
result is RESULT and the function is FUNCTION. If RESULT does not
appear, result is FUNCTION and function is RESULT".

-- CyrMag

Re: CALL FOO when FOO is a function

<803b5fb1-0aa2-4fba-a192-15d661c8f03cn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:6214:2b09:b0:45b:59b:5df6 with SMTP id jx9-20020a0562142b0900b0045b059b5df6mr15621048qvb.22.1653280883959;
Sun, 22 May 2022 21:41:23 -0700 (PDT)
X-Received: by 2002:a25:84c6:0:b0:64f:581e:dc77 with SMTP id
x6-20020a2584c6000000b0064f581edc77mr14213643ybm.92.1653280883678; Sun, 22
May 2022 21:41:23 -0700 (PDT)
Path: i2pn2.org!rocksolid2!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Sun, 22 May 2022 21:41:23 -0700 (PDT)
In-Reply-To: <t6eqqp$p64$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=115.189.134.122; posting-account=KnYfEgoAAAD1tUJTvdAUZ3XojNa5tezZ
NNTP-Posting-Host: 115.189.134.122
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>
<_n9iK.4090$Dr6.3622@fx06.iad> <0001HW.283A8CCC007734B470000210D38F@news.eternal-september.org>
<CYuiK.16679$wIO9.3518@fx12.iad> <t6e0ac$1rcrn$1@dont-email.me> <t6eqqp$p64$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <803b5fb1-0aa2-4fba-a192-15d661c8f03cn@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: harperjf2@gmail.com (jfh)
Injection-Date: Mon, 23 May 2022 04:41:23 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3156
 by: jfh - Mon, 23 May 2022 04:41 UTC

On Monday, May 23, 2022 at 2:17:01 PM UTC+12, CyrMag wrote:
> On 5/22/2022 1:44 PM, James Van Buskirk wrote:
> <--SNIP-->
> > It's kind of mind-bending to think about the function foo and the
> > result variable foo as different things with the same name in
> > the seminal example of this thread, but different things can indeed
> > have the same name. If you google my name the first thing it comes
> > up with is some pervert from the West Coast. Another thing about
> > names with which we are all familiar:
> > https://en.wikipedia.org/wiki/Haddocks%27_Eyes
>
> Not only the same name, as James writes, but sometimes we use the same
> notation but with different meanings.
>
> Indeed, having multiple purposes/meanings of parentheses -- to hold a
> sequence of subprogram arguments, and also to hold subscripts -- is the
> cause of so many complicated and confusing rules. Had we used the
> notation of other programming languages, "foo(n)" would be a function
> invocation and "foo[n]" would be the n-th or (n+1)th element of array
> "foo".
> <-SNIP->

That would give [ ] multiple meanings. If you think parentheses have too many meanings in Fortran, what about the asterisk? It had 20 the last time I looked, and many of them are not obsolescent.

Re: CALL FOO when FOO is a function

<0001HW.283BF0C700CAA2CD70000D53538F@news.eternal-september.org>

  copy mid

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

  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: Mon, 23 May 2022 10:41:43 -0600
Organization: A noiseless patient Spider
Lines: 139
Message-ID: <0001HW.283BF0C700CAA2CD70000D53538F@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> <0001HW.28393C2E0028507570000EA3538F@news.eternal-september.org> <_n9iK.4090$Dr6.3622@fx06.iad> <0001HW.283A8CCC007734B470000210D38F@news.eternal-september.org> <CYuiK.16679$wIO9.3518@fx12.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="8c7ef33d09c16c7f3f6175b7d46e48df";
logging-data="14278"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18sqo8L1zajhwtq+8VDhyNLvG9AQSTzutk="
User-Agent: Hogwasher/5.24
Cancel-Lock: sha1:r0On31axu9GUOkgc15Lj1vcigns=
 by: Dan Nagle - Mon, 23 May 2022 16:41 UTC

Hi,

On May 22, 2022, Ron Shepard wrote
(in article <CYuiK.16679$wIO9.3518@fx12.iad>):

> On 5/22/22 10:22 AM, Dan Nagle wrote:
> [...]
> > The function result variable inherits all the characteristics
> > of the function name.
>
> Your claim would seem to apply to both cases, with and without the
> result() clause. Yet you have already stated that it doesn't, that it
> only applies to the case without the result() clause.

Because that is the same name in the result variable and the function.
I have posted that I believe the code is valid, provided a differently-named
result variable is used.

I claim (again) that declarations may not contradict each other.

>
>
> Or are you claiming that with result(r), the entity r is not the result
> variable? Or that the entity r does not inherit all the characteristics
> of foo, the function name.
>
> Either way, it seems like a contradiction to the above statement?
>
> >
> > The statement declaring foo to be a pointer to subroutine
> > is invalid because it attempts to change the characteristics of foo.
>
> Yet, with the result() clause you claim that the same thing is allowed.
> Isn't this inconsistent with your above argument?

No, because with a result clause, the same name in the same scope
is not being given contradictory characteristics.

<snip>

> Here is another example of
> this, which I think is conforming:
>
> program func
> write(*,*) foo(3)
> contains
> function foo(n)
> integer :: foo(2) ! return an integer array.
> integer, intent(in) :: n
> foo(1) = -n
> foo(2) = n
> return
> end function foo
> end program func
>
> Note that there is no result() clause. The result of the function is an
> integer array, so result() is not necessary simply to declare an array
> valued function. Also, within the function body, the references to
> foo(1) and foo(2) are to the elements of the integer array, they are not
> recursive references to the function with its single integer argument.
>
> Is this small program conforming?

Where does a declaration contradict another declaration?

>
>
> [...]
> > result was also added to allow the function value to be an array.
>
> The example above shows that result() is not required for this purpose.
>
> > (This is one reason why result variables inherit all characteristics
> > of the function name- you want the array to have the correct shape.)
>
> See the above example which contradicts this statement.

Again, where are the contradictory declarations?

<snip>

>
> There is no ambiguity. Without the result() clause, all references to
> foo within the function body are to its value as an integer array in the
> above example, and to a procedure pointer in the example being discussed.

But your example declaration (integer function) the later declaration
does not contradict the earlier one.

Look, the statement "function foo" declares foo to be a function.
Declaring foo's return value to be a pointer-to-subroutine contradicts that,
if you try to use the same name. Declaring foo to return an integer array
does not contradict foo being a function.

>
>
> >
> > Whether foo is a function or a subroutine is a characteristic
> > that cannot change.
>
> foo is a function, and its value is a procedure pointer.

Correct. Which is why, in the same scope, they both cannot
be declared using the same name.

>
>
> > foo is a function because it is the name in a function statement.
> > The type of foo is irrelevant.
>
> This statement is not consistent with the above example. There foo is a
> function, and the type of its value is an integer array. References such
> as foo(1) within the body of the function are to the integer array, not
> recursive references to the function.

Note that "subsequent declaration" and "contradictory declaration" are
different cases.

Please.

Comment

A code is not standard-conforming unless the standard says what it means.

Fortran allows declarations of one name in one scope to be spread across
several statements. But the incremental declarations must all be consistent.

Recall that the OP asked why so many compilers "crash hard with internal
errors".
My answer is that many compilers have not seen a lot of code with procedure
pointers,
and they do not yet catch all the errors they might (and possibly will
someday).

--
Cheers!

Dan Nagle

Re: CALL FOO when FOO is a function

<jf2jmnFjfloU1@mid.individual.net>

  copy mid

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

  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: Mon, 23 May 2022 19:29:25 -0400
Lines: 82
Message-ID: <jf2jmnFjfloU1@mid.individual.net>
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
X-Trace: individual.net GrA6TwU2weclNEP0Uu3sgQ6GwqTqLGrIPWMfDm7Hfc0osOtOUT
Cancel-Lock: sha1:fEuXuKubS6I3nXtR822EhA5BsyU=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Content-Language: en-US
In-Reply-To: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
 by: Steve Lionel - Mon, 23 May 2022 23:29 UTC

On 5/18/2022 11:39 AM, 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
>

I respectfully disagree with Dan Nagle here.

Referencing Fortran 2018, 15.6.2.2 (Function subprogram), paragraph 3, says:

"The type and type parameters (if any) of the result of the function
defined by a function subprogram may be specified by a type
specification in the FUNCTION statement or by the name of the function
result appearing in a type declaration statement in the specification
part of the function subprogram. They shall not be specified both ways.
If they are not specified either way, they are determined by the
implicit typing rules in effect within the function subprogram. If the
function result is an array, allocatable, or a pointer, this shall be
specified by specifications of the name of the function result within
the function body. The specifications of the function result attributes,
the specification of dummy argument attributes, and the information in
the procedure heading collectively define the characteristics of the
function (15.3.1)"

P4 then says, in part, "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."

NOTE 1 then says, "The function result is similar to any other entity
(variable or procedure pointer) local to a function subprogram. Its
existence begins when execution of the function is initiated and ends
when execution of the
function is terminated."

Within the function, FOO is not a function, it is a local variable that
is the function result. Its characteristics are those declared in the
specification section as a procedure pointer with interface (BAR), which
happens to be a subroutine. This is fine, and there is no conflict or
duplicate declaration.

If we were to accept Dan's position that the FUNCTION statement causes
the function result to be a function, a function such as:

function BAZ ()
REAL :: BAZ
BAZ = 3.0
end function BAZ

would be invalid, since you can't assign 3.0 to a function.

This case is confusing, I'll admit. I note that NAG Fortran 7.1 rejects
it, complaining of a recursive reference to FOO. I'm going to run this
by the committee and see what they think. (I'll also report the ICE to
Intel, though not before I get an answer as to what it is supposed to do.)

--
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

<295170f1-2d8d-4061-8bcb-dea51b964606n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:6214:c8e:b0:462:3bd6:d507 with SMTP id r14-20020a0562140c8e00b004623bd6d507mr6502443qvr.77.1653360956956;
Mon, 23 May 2022 19:55:56 -0700 (PDT)
X-Received: by 2002:a81:18cc:0:b0:2ff:4211:14a2 with SMTP id
195-20020a8118cc000000b002ff421114a2mr25918505ywy.508.1653360956773; Mon, 23
May 2022 19:55:56 -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: Mon, 23 May 2022 19:55:56 -0700 (PDT)
In-Reply-To: <jf2jmnFjfloU1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:991e:5741:8043:efee;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:991e:5741:8043:efee
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com> <jf2jmnFjfloU1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <295170f1-2d8d-4061-8bcb-dea51b964606n@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: gah4@u.washington.edu (gah4)
Injection-Date: Tue, 24 May 2022 02:55:56 +0000
Content-Type: text/plain; charset="UTF-8"
 by: gah4 - Tue, 24 May 2022 02:55 UTC

On Monday, May 23, 2022 at 4:29:31 PM UTC-7, Steve Lionel wrote:

(snip)

> This case is confusing, I'll admit. I note that NAG Fortran 7.1 rejects
> it, complaining of a recursive reference to FOO. I'm going to run this
> by the committee and see what they think. (I'll also report the ICE to
> Intel, though not before I get an answer as to what it is supposed to do.)

Much of this can be confusing to humans, if not the compiler.

Since you can't call integers, or add functions, we know the difference
between an integer variable and procedure pointer.

I know it slightly better in C, and maybe it is a little less confusing.

In C you can declare a function:

double fun();

or a function pointer:

double (*fp)();

Also, in C () is the function call operator, similar to the way [] is the
array reference operator. (It isn't quite as easy in Fortran.)

You can assign to a function pointer:

fp=sqrt; // no () operator

and call a function using a dereferenced function pointer:

x=(*fp)(2.0);

However, it seems that C lets you get away with calling a function
pointer instead of a function:

x=fp(2.0);
even though maybe it shouldn't.

But now, consider a function that returns a function pointer.

Here is one place where the difference between C and Fortran appears.
In C, you can reference an array element of an array (actually
a pointer) returned by a function:

double *af();
x = af()[0];

while Fortran requires assigning the function value to an array.

But now, consider a function returning a function pointer,
a function pointer to such function, and reference using it.
and then a call to the function from the returned pointer.

Declare function pointer to function returning a function pointer:
double (*(*fpp)())();

Declare function returning a function pointer:
double (*ffp())();

ffp=fpp; // point to the function

Call the function, and then the returned function:

printf("%f\n", (*fpp())(3.14));

or call it this way:

printf("%f\n", (fpp())(3.14));

I don't know how to write or call functions returning function pointers,
or pointers to them in Fortran. Here is the whole C program:

#include <stdio.h>
#include <math.h>
int main() {
double (*fp)();
double (*(*fpp)())();
double (*ffp())();
fp=sqrt;
printf("%f\n", (*fp)(2.0));
printf("%f\n", fp(2.0));
fpp = ffp;
printf("%f\n", (*fpp())(3.14));
printf("%f\n", (fpp())(3.14));
}

double (*ffp())() {
return cos;
}

Re: CALL FOO when FOO is a function

<439c5980-435b-4448-a22d-f5d47e61f442n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:ac8:5b44:0:b0:2f9:3470:678f with SMTP id n4-20020ac85b44000000b002f93470678fmr6732516qtw.287.1653362125114;
Mon, 23 May 2022 20:15:25 -0700 (PDT)
X-Received: by 2002:a81:9b0c:0:b0:2f4:c522:7d3c with SMTP id
s12-20020a819b0c000000b002f4c5227d3cmr26974581ywg.316.1653362124859; Mon, 23
May 2022 20:15:24 -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: Mon, 23 May 2022 20:15:24 -0700 (PDT)
In-Reply-To: <jf2jmnFjfloU1@mid.individual.net>
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> <jf2jmnFjfloU1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <439c5980-435b-4448-a22d-f5d47e61f442n@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: parekhvs@gmail.com (FortranFan)
Injection-Date: Tue, 24 May 2022 03:15:25 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2223
 by: FortranFan - Tue, 24 May 2022 03:15 UTC

On Monday, May 23, 2022 at 7:29:31 PM UTC-4, Steve Lionel wrote:

> ..
> This case is confusing, I'll admit. I note that NAG Fortran 7.1 rejects
> it, complaining of a recursive reference to FOO. I'm going to run this
> by the committee and see what they think.

Given OP's first line, "Only one Fortran compiler can cope with this usage," I had been wondering whether NAG Fortran was the one that managed to "cope with this usage". Your note that "NAG Fortran 7.1 rejects it, complaining of a recursive reference to FOO" is interesting. The note by @Juergen Reuter upthread, ".. 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)" had indicated the same.

Given the situation, your plan that "I'm going to run this by the committee and see what they think" is perfect. Thank you, it will be very helpful to learn of the committee feedback.

Re: CALL FOO when FOO is a function

<jf447pFs6tvU1@mid.individual.net>

  copy mid

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

  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: Tue, 24 May 2022 09:17:45 -0400
Lines: 21
Message-ID: <jf447pFs6tvU1@mid.individual.net>
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
<jf2jmnFjfloU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net xKOiJ+I0O3nfeQyex5Hd8QVwfVnZEZ0a9Eef4mk1D/UScCJYik
Cancel-Lock: sha1:HGky+qQbtd1qvrVVYUsbCBhPNLQ=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Content-Language: en-US
In-Reply-To: <jf2jmnFjfloU1@mid.individual.net>
 by: Steve Lionel - Tue, 24 May 2022 13:17 UTC

On 5/23/2022 7:29 PM, Steve Lionel wrote:
> This case is confusing, I'll admit. I note that NAG Fortran 7.1 rejects
> it, complaining of a recursive reference to FOO. I'm going to run this
> by the committee and see what they think. (I'll also report the ICE to
> Intel, though not before I get an answer as to what it is supposed to do.)

Malcolm Cohen (NAG Fortran, standard editor) said, "There is no doubt
that within FOO, FOO is the eponymous result name, not the name of the
subprogram. This is similar to functions returning arrays – within an
array function F with no RESULT clause, F(I,J) is an array element of
the result, not a recursive self-reference."

--
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

<97c4c98a-7285-48de-9e4d-0bec06cde9fan@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:6214:d4d:b0:462:4986:f9bd with SMTP id 13-20020a0562140d4d00b004624986f9bdmr7834327qvr.70.1653435582169;
Tue, 24 May 2022 16:39:42 -0700 (PDT)
X-Received: by 2002:a81:5ec5:0:b0:2ff:a079:f0d9 with SMTP id
s188-20020a815ec5000000b002ffa079f0d9mr20391193ywb.459.1653435581911; Tue, 24
May 2022 16:39:41 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Tue, 24 May 2022 16:39:41 -0700 (PDT)
In-Reply-To: <jf447pFs6tvU1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=98.194.164.24; posting-account=YGTUIQoAAAAFR372MRGEUx-D9N1L7CrN
NNTP-Posting-Host: 98.194.164.24
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
<jf2jmnFjfloU1@mid.individual.net> <jf447pFs6tvU1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <97c4c98a-7285-48de-9e4d-0bec06cde9fan@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: cyrmag7@gmail.com (CyrMag)
Injection-Date: Tue, 24 May 2022 23:39:42 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2535
 by: CyrMag - Tue, 24 May 2022 23:39 UTC

On Tuesday, May 24, 2022 at 8:17:49 AM UTC-5, Steve Lionel wrote:
> On 5/23/2022 7:29 PM, Steve Lionel wrote:
> > This case is confusing, I'll admit. I note that NAG Fortran 7.1 rejects
> > it, complaining of a recursive reference to FOO. I'm going to run this
> > by the committee and see what they think. (I'll also report the ICE to
> > Intel, though not before I get an answer as to what it is supposed to do.)
> Malcolm Cohen (NAG Fortran, standard editor) said, "There is no doubt
> that within FOO, FOO is the eponymous result name, not the name of the
> subprogram. This is similar to functions returning arrays – within an
> array function F with no RESULT clause, F(I,J) is an array element of
> the result, not a recursive self-reference."
> --
> Steve Lionel

In that case, the comment by PMK in the code fragment in the leading post:

call foo ! <-- CALL of a function

is incorrect, and perhaps misleading. On this line, "foo" is not the function FOO, but a pointer that is associated with a subroutine, and it is that subroutine that is being called through the pointer, and there is no the function itself being (recursively or otherwise) "called", as the comment suggests.

Do you agree, Steve L.?

-- Cyrmag

Re: CALL FOO when FOO is a function

<0052ff63-2395-4d1e-a637-5c3a3da092f3n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:622a:3c6:b0:2f3:f7d6:63e0 with SMTP id k6-20020a05622a03c600b002f3f7d663e0mr23023224qtx.530.1653442014832;
Tue, 24 May 2022 18:26:54 -0700 (PDT)
X-Received: by 2002:a81:1154:0:b0:2fe:d5a4:f26b with SMTP id
81-20020a811154000000b002fed5a4f26bmr32172280ywr.140.1653442014642; Tue, 24
May 2022 18:26:54 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.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: Tue, 24 May 2022 18:26:54 -0700 (PDT)
In-Reply-To: <jf447pFs6tvU1@mid.individual.net>
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>
<jf2jmnFjfloU1@mid.individual.net> <jf447pFs6tvU1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <0052ff63-2395-4d1e-a637-5c3a3da092f3n@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: parekhvs@gmail.com (FortranFan)
Injection-Date: Wed, 25 May 2022 01:26:54 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1808
 by: FortranFan - Wed, 25 May 2022 01:26 UTC

On Tuesday, May 24, 2022 at 9:17:49 AM UTC-4, Steve Lionel wrote:
> ..
> Malcolm Cohen (NAG Fortran, standard editor) said, "There is no doubt
> that within FOO, FOO is the eponymous result name, not the name of the
> subprogram. This is similar to functions returning arrays – within an
> array function F with no RESULT clause, F(I,J) is an array element of
> the result, not a recursive self-reference." ..

Thank you for the follow-up, that is very useful to know. I wonder whether NAG Fortran team will open up a support incident on this.

Re: CALL FOO when FOO is a function

<afcfcba1-449e-4587-a592-86dd6e935d01n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.fortran
X-Received: by 2002:a05:620a:956:b0:6a3:735f:f7ad with SMTP id w22-20020a05620a095600b006a3735ff7admr12407704qkw.717.1653479004895;
Wed, 25 May 2022 04:43:24 -0700 (PDT)
X-Received: by 2002:a5b:489:0:b0:655:be22:4757 with SMTP id
n9-20020a5b0489000000b00655be224757mr1792216ybp.92.1653479004725; Wed, 25 May
2022 04:43:24 -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, 25 May 2022 04:43:24 -0700 (PDT)
In-Reply-To: <jf2jmnFjfloU1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=2601:602:9700:4689:1406:e943:7011:53b2;
posting-account=gLDX1AkAAAA26M5HM-O3sVMAXdxK9FPA
NNTP-Posting-Host: 2601:602:9700:4689:1406:e943:7011:53b2
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com> <jf2jmnFjfloU1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <afcfcba1-449e-4587-a592-86dd6e935d01n@googlegroups.com>
Subject: Re: CALL FOO when FOO is a function
From: gah4@u.washington.edu (gah4)
Injection-Date: Wed, 25 May 2022 11:43:24 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2073
 by: gah4 - Wed, 25 May 2022 11:43 UTC

On Monday, May 23, 2022 at 4:29:31 PM UTC-7, Steve Lionel wrote:

(snip)

> If we were to accept Dan's position that the FUNCTION statement causes
> the function result to be a function, a function such as:
> function BAZ ()
> REAL :: BAZ
> BAZ = 3.0
> end function BAZ
> would be invalid, since you can't assign 3.0 to a function.
It seems to me that isn't quite right. Variables can have different
attributes, depending on where they are used.

My first thought is that I should be able to use an array as a DO
variable, since I can assign one in an assignment statement.

integer i(10)
do i=1,10
print *,i
enddo

I expect this not to work, even though there is nothing wrong
with assigning to i.

But yes, in an assignment statement BAZ is an integer variable,
and not a function, so the assignment works.

Re: CALL FOO when FOO is a function

<jf7mu5FitrlU1@mid.individual.net>

  copy mid

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

  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, 25 May 2022 17:55:16 -0400
Lines: 14
Message-ID: <jf7mu5FitrlU1@mid.individual.net>
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
<jf2jmnFjfloU1@mid.individual.net> <jf447pFs6tvU1@mid.individual.net>
<0052ff63-2395-4d1e-a637-5c3a3da092f3n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net 9P2JtzR2R689t10Kr44wSARns8gjJmG355a8VVuVylW+CinfVi
Cancel-Lock: sha1:nH+WfFnqb77kH4tpg+2dEWKhzLw=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Content-Language: en-US
In-Reply-To: <0052ff63-2395-4d1e-a637-5c3a3da092f3n@googlegroups.com>
 by: Steve Lionel - Wed, 25 May 2022 21:55 UTC

On 5/24/2022 9:26 PM, FortranFan wrote:
> Thank you for the follow-up, that is very useful to know. I wonder whether NAG Fortran team will open up a support incident on this.

Yes, Malcolm filed one. I have also reported the ICE to Intel.

--
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

<jf7muqFitrlU2@mid.individual.net>

  copy mid

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

  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, 25 May 2022 17:55:37 -0400
Lines: 18
Message-ID: <jf7muqFitrlU2@mid.individual.net>
References: <6686b133-796b-4dd6-aa5f-b82d9f18a1f2n@googlegroups.com>
<jf2jmnFjfloU1@mid.individual.net> <jf447pFs6tvU1@mid.individual.net>
<97c4c98a-7285-48de-9e4d-0bec06cde9fan@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net HQ8m3nkEsh9ahMhhpWbnoQk7v6qaPfd2dmTcI9Q7koji9An9nm
Cancel-Lock: sha1:61bv9UJHmhHuWXg/NRSogjdyAh4=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.1
Content-Language: en-US
In-Reply-To: <97c4c98a-7285-48de-9e4d-0bec06cde9fan@googlegroups.com>
 by: Steve Lionel - Wed, 25 May 2022 21:55 UTC

On 5/24/2022 7:39 PM, CyrMag wrote:
> In that case, the comment by PMK in the code fragment in the leading post:
>
> call foo ! <-- CALL of a function
>
> is incorrect, and perhaps misleading.

Yes.

--
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

Pages:12
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor