Re: How to detect NULL input?



glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxxxxxxxxx> wrote:

> Richard E Maine <nospam@xxxxxxxxxxxxx> wrote:
> > Rich Townsend <rhdt@xxxxxxxxxxxxxxxxxxx> wrote:
> >
> >> Fair enough. BTW, was result primarily introduced to support recursive
> > functions?
>
> > That's my impression. It was introduced in f90, before I was on J3, and
> > I don't recall ever explicitly asking, but I would assign a reasonably
> > high degree of confidence tothat guess.
>
> In the early days of Fortran, when all variables were static
> including the function return value, I could see the problem.

Huh? I don't even know what that has to do with the problem. The problem
has nothing at all to do with static vs dynamic or anything like that.
It is purely a matter of syntax. If one had, say, a recursive array
function f, then without the result clause, there would be cases where
one could not tell whether f(1) was a recursive function reference or
just a reference to the first element of the result variable for this
function.

> Is there a requirement that the function return variable be
> static in versions allowing recursion?

To my knowledge, the word "static" doesn't even appear in the language
(not that I really bothered to check). It certainly does not appear in
this regard; nor does any other word with the same implication. Rather
the opposite, I don't see an obvious way to implement recursive
functions with a static result variable. If someone can come up with
some obscure way to do so, it certainly isn't the norm. I doubt that a
single such implementation exists.

> Also, there is a tradition (in the case of ENTRY) that all function
> return variables are EQUIVALENCEd. Does it still do that, even
> in the case of recursive functions not using a function return variable?

1. Nothing in that regard is special-cased for recusrion. Yes, it still
works the same way. This seems to me unrelated to the question of why
the result clause was added.

2. *ALL* functions have a function result variable. The only thing that
th eresult clause does is give that variable a different name. But a
variable exists regardless. If you think of functions as not having
result variables, you will be lead down many wrong paths.

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
.



Relevant Pages

  • Re: How to detect NULL input?
    ... there is a tradition (in the case of ENTRY) that all function ... Nothing in that regard is special-cased for recusrion. ... I was considering complications of ENTRY and recursion, ...
    (comp.lang.fortran)
  • Re: How to secure Windows 2000 DNS
    ... >> regard to inbound interface. ... > not do recursion for anyone on the outside? ... >>> DNS server for information on a host in a domain I am not hosting, ...
    (microsoft.public.windows.server.dns)