Variable length argument list in Fortran?

Viewed 774

Has Fortran ever gotten around to handling subroutine argument lists with arbitrary length, like C can do? (BTW, "present" isn't going to work for what I am trying to do.) Thanks.

1 Answers

There are no such subroutines in Fortran.

The syntax rule for a subroutine statement in Fortran 2008 is (12.6.2.3, R1235):

[ prefix ] SUBROUTINE subroutine-name [ ( [ dummy-arg-list ] ) [ proc-language-binding-spec ] ]

where dummy-arg-list is a list (in assumed syntax rule terms) of dummy-args. A dummy-arg is (R1235) either a name or a literal *.

[Before we get too excited about the possibility of variadic support, the * refers, of course, to an alternate return indicator.]

A list (R101) still refers to a well-defined (at source time) number of items.

There is a stated restriction regarding interoperability with C, that (15.3.7) the C prototype

... does not have variable arguments as denoted by the ellipsis (...)

Similar arguments apply to (Fortran) functions.

Related