Re: How to detect NULL input?



Richard E Maine <nospam@xxxxxxxxxxxxx> wrote:
> 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.

OK, I was completely confused on this one. I thought that
there was now the ability to specify function return values
on the RETURN statement, but it doesn't seem that there is.

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

I don't think that is what I meant.


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

It does seem that there are complications with ENTRY, such that
array valued functions are not allowed. That is the type of
complication I was thinking of.


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

Yes. I was considering complications of ENTRY and recursion,
but it seems that ENTRY forbids array value functions.
Result does allow the convenience of only one name for a return
value for a function with multiple ENTRY points.

-- glen
.



Relevant Pages

  • Re: GOBACK (was: Perform Thru/Go to vs. Perform - Compile Speed
    ... For a start I never argued for recursion. ... That may not represent a limitation of 'other languages'. ... > make the paragraph an external program. ... take a parameter the _whole_program_ should be changed to using ENTRY ...
    (comp.lang.cobol)
  • Re: Searching for a file - in a tree?
    ... all directories to an array, and by a counter I work my way through ... Pseudocode which finds a single entry. ... Open startdir ... (this is the recursion call) ...
    (comp.lang.php)
  • Re: GOBACK (was: Perform Thru/Go to vs. Perform - Compile Speed
    ... robert.deletethis@wagner.net (Robert Wagner) wrote ... significance if the code is to be reused with different data items, ... There are very few real cases for using recursion. ... ENTRY was designed to support is re-entrancy. ...
    (comp.lang.cobol)
  • Re: find a number
    ... You need GnuPG to verify this message ... Sorry I got a bit lost in your description, but I was thinking sort of ... as you do and for each entry you read the entry and then you recurse on ... until there are not more numbers left, at that point the recursion goes ...
    (comp.lang.java.programmer)
  • 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)