comp.lang.ada
 help / color / mirror / Atom feed
From: slinky.cs.nyu.edu!slinky.cs.nyu.edu!nobody@nyu.edu  (Robert Dewar)
Subject: Re: QUERY ABOUT MONITOR
Date: 10 Aug 93 14:00:38 GMT	[thread overview]
Message-ID: <2489m6$2ht@schonberg.cs.nyu.edu> (raw)

Mike repeats a common myth about Fortran, namely that it requires arrays to
be passed by reference. This is rubbish. In fact Ada tried to copy Fortran's
approach carefully. Both Ada and Fortran allow composite objects to be passed
by reference or value, as decided by the compiler. Any Fortran code that
counts on pass by reference is faulty (Mike if you don't believe this, settl
down with the Fortran standard, it's perfectly clear there).

However, in practice, both in Ada and Fortran, arrays are typically passed by
reference, so this is from a pragmatic point of view a non-issue.

All Ada compilers I know of lay out arrays contiguously (interestingly enough
Mike makes the opposite mistake here, Fortran DOES require arrays to be laid
out contiguously, it's not an obvious requirement, but it is a ramification
of the rules for passing arrays in Fortran). So that also is not in practice
a problem.

Now what about passing descriptors etc. Well we obviously must have pragma
Interface FORTRAN available in an Ada compiler to interface to Fortran. To
try such an interface if the Ada compiler does not intend to allow it is
of course hazardous at best, and unlikely to work. If pragma Interface 
FORTRAN is available, then of course any reasonable implementation of it
will pass arrays in the Fortran manner (typically passing the address of
the first element, or perhaps the virtual array origin if this is how the
fortran compiler works). 

On the other hand you would neither expect nor want it to make a copy of
the array into column-major form, so you would normally expect, in an Ada 83
context, to have to flip the subscripts on the Ada side, which is an annoyance
but not a disaster (I certainly think it's a reasonable frill to add the
relevant pragma in Ada 9X).

The point here is that the mapping of arrays is not the fundamental issue
in a Fortran binding. If Mike is working with a compiler that tries to
pass array descriptors to a subprogram to which pragma Interface FORTRAN
is applied, then that compiler is broken. If he is working with a compiler
that has no pragma Interface FORTRAN at all, then clearly that is not the
tool to interface Ada and Fortran!

P.S. I keep forgetting, but the name FORTRAN has been officially changed to
Fortran now, very confusing!

             reply	other threads:[~1993-08-10 14:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-08-10 14:00 Robert Dewar [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-08-11  0:05 QUERY ABOUT MONITOR Michael Feldman
1993-08-10  2:01 cis.ohio-state.edu!math.ohio-state.edu!darwin.sura.net!seas.gwu.edu!mfeld
1993-08-09  5:08 Robert Dewar
1993-08-04  2:43 Michael Feldman
1993-08-02 22:26 cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!darwin.sura
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox