From: steve on
All,

I was reading through the description of get_command_argument(). It
has the form get_command_argument(number [, value, length, status])
where number is the argument number that one wants information.
value, length, and status are option, and from the description none of
these are required. Thus.

program a
call get_command_argument(0)
end program a

is a valid, yet useless program. Is there a missing requirement
that one of the optional arguments should be supplied?

--
steve
From: Richard Maine on
steve <kargls(a)comcast.net> wrote:

> program a
> call get_command_argument(0)
> end program a
>
> is a valid, yet useless program. Is there a missing requirement
> that one of the optional arguments should be supplied?

No. The Fortran standard does not generally go out of its way to specify
that users are not allowed to write useless programs. That would, I'm
afraid, be a bit beyond the capabilities of the committee to adequately
specify.

It isn't as though this is even the only intrinsic procedure with the
same property of having useless forms with no arguments. See
date_and_time for something directly comparable.

Nor is this something that looks particularly inviting to error. In
fact, useless as it might appear, I'd bet that if the standard were
changed to prohibit the useless form, someone would complain that this
was a pointless prohibition that broke some code of theirs. Let's see if
I can imagine how someone might actually have code like that.... Hmm...
Maybe generated as the trivial case by some kind of macro or other auto
code generator when none of the data was needed? I don't know how
realistic that is, but that's the first thing that came to mind.

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
From: Ron Shepard on
In article <1jkcw1d.bu8alrl4bx6mN%nospam(a)see.signature>,
nospam(a)see.signature (Richard Maine) wrote:

> steve <kargls(a)comcast.net> wrote:
>
> > program a
> > call get_command_argument(0)
> > end program a
> >
> > is a valid, yet useless program. Is there a missing requirement
> > that one of the optional arguments should be supplied?
>
> No. The Fortran standard does not generally go out of its way to specify
> that users are not allowed to write useless programs. That would, I'm
> afraid, be a bit beyond the capabilities of the committee to adequately
> specify.
>
> It isn't as though this is even the only intrinsic procedure with the
> same property of having useless forms with no arguments. See
> date_and_time for something directly comparable.
>
> Nor is this something that looks particularly inviting to error. In
> fact, useless as it might appear, I'd bet that if the standard were
> changed to prohibit the useless form, someone would complain that this
> was a pointless prohibition that broke some code of theirs. Let's see if
> I can imagine how someone might actually have code like that.... Hmm...
> Maybe generated as the trivial case by some kind of macro or other auto
> code generator when none of the data was needed? I don't know how
> realistic that is, but that's the first thing that came to mind.

The other way these things can occur is with a call such as

call get_command_argument(0, value, length, status)

where the variables value, length, and status are themselves
optional dummy arguments. If none of them are present in the
calling program, then it has the same effect as above -- none of the
optional arguments are present in the call. The subroutine cannot
tell the difference in these cases, the present(argument) result
works the same either way. However, to avoid making such calls, the
programmer would need to test all of the variables and write the
appropriate conditional code to handle the cases (up to eight =2^3
in this case) where some or all of the variables are not present.
In many cases, that would be a useless waste of time, and lines of
code, so things are just simpler in this case if optional arguments
are optional, and not sometimes optional and sometimes required.
Also, it would be impossible for the compiler to test this situation
at compile time, so if it is a compiler error or warning that is
desired, then only a subset of the missing-argument cases could be
detected by the compiler.

$.02 -Ron Shepard
From: steve on
On Jun 20, 7:18 am, Ron Shepard <ron-shep...(a)NOSPAM.comcast.net>
wrote:
> In article <1jkcw1d.bu8alrl4bx6mN%nos...(a)see.signature>,
>  nos...(a)see.signature (Richard Maine) wrote:
>
>
>
> > steve <kar...(a)comcast.net> wrote:
>
> > >    program a
> > >         call get_command_argument(0)
> > >    end program a
>
> > > is a valid, yet useless program.  Is there a missing requirement
> > > that one of the optional arguments should be supplied?
>
> > No. The Fortran standard does not generally go out of its way to specify
> > that users are not allowed to write useless programs. That would, I'm
> > afraid, be a bit beyond the capabilities of the committee to adequately
> > specify.
>
> > It isn't as though this is even the only intrinsic procedure with the
> > same property of having useless forms with no arguments. See
> > date_and_time for something directly comparable.
>
> > Nor is this something that looks particularly inviting to error. In
> > fact, useless as it might appear, I'd bet that if the standard were
> > changed to prohibit the useless form, someone would complain that this
> > was a pointless prohibition that broke some code of theirs. Let's see if
> > I can imagine how someone might actually have code like that.... Hmm...
> > Maybe generated as the trivial case by some kind of macro or other auto
> > code generator when none of the data was needed? I don't know how
> > realistic that is, but that's the first thing that came to mind.
>
> The other way these things can occur is with a call such as
>
>   call get_command_argument(0, value, length, status)
>
> where the variables value, length, and status are themselves
> optional dummy arguments.  If none of them are present in the
> calling program, then it has the same effect as above -- none of the
> optional arguments are present in the call.  The subroutine cannot
> tell the difference in these cases, the present(argument) result
> works the same either way.  However, to avoid making such calls, the
> programmer would need to test all of the variables and write the
> appropriate conditional code to handle the cases (up to eight =2^3
> in this case) where some or all of the variables are not present.  
> In many cases, that would be a useless waste of time, and lines of
> code, so things are just simpler in this case if optional arguments
> are optional, and not sometimes optional and sometimes required.  
> Also, it would be impossible for the compiler to test this situation
> at compile time, so if it is a compiler error or warning that is
> desired, then only a subset of the missing-argument cases could be
> detected by the compiler.

Thanks Richard and Ron. Ron, your example surely is the
root of the decision.

--
steve