Variable-length arrays

Tom MacDonald uunet!fig.cray.com!tam
Thu Dec 19 10:09:30 PST 1991


>>>>> Peter S. Shenkin asks:
> By the way, would Fortran require n to be declared first?

Fortran is not a good model here.  For instance

	SUBROUTINE JOE(A,N)
	REAL A(N,N)

is allowed because `N' defaults to type INTEGER and the names
are introduced prior to the full declaration.  Fortran does
not have any file scope names either.  The subroutine is the
entire compilation unit.  File scope names are also part of
the issue.

As Richard Stallman points out

	void JOE(a,n)
	   int n;
	   float a[n];

solves the problem and is a Fortran analogy.  However, the C
Standard introduces the function prototype concept and also
introduced the lexical ordering problem.  Since function
prototypes are the wave of the future we need to deal with
them.

I do agree that the burden on the compiler is a secondary issue.
The Cray Research implementation of Variable Length Arrays (VLA)
is oriented around the programmer and not the implementation
difficulties.  We knew this would generate interesting debates
and we haven't been let down.

My own personal opinion is that programmers should not be forced
to specify parameters in a particular order.   A common programming
style is to put the most important arguments first.  A VLA feature
should should not force an ordering.  It appears that the current
feature proposals are cognizant of this issue and I'm happy about
that.

now-all-we-have-to-do-is-agree-on-*one*-ly yours,

Tom MacDonald
tamacray.com
uunet!cray!tam



More information about the Numeric-interest mailing list