comp.lang.ada
 help / color / mirror / Atom feed
* Beginner's question (array parameters to functions)
@ 1998-11-27  0:00 greg
  1998-11-28  0:00 ` Matthew Heaney
  1998-11-28  0:00 ` Tom Moran
  0 siblings, 2 replies; 8+ messages in thread
From: greg @ 1998-11-27  0:00 UTC (permalink / raw)


I have a homework assignment which involves writing an Ada program that
sorts an array of items.  One requirement of the assignment is that the
sorting be done by a function which takes the array as a parameter and
returns a sorted array.  The other details of the assignment (the
particular sorting method to use, etc.) are not pertinent to my question
so I do not mention them here.
My question is the following:  As I understand it, in an Ada function, a
parameter must be passed in "in" mode.  Therefore, I assume that in this
assignment, the sorting function has to make a copy of the array
parameter, sort the items in this second array, and finally return this
second array to the caller subprogram, because, given that the array is
passed as a parameter, there is no way to change the values of the array
that is copied in for use in the function.

(I realize that it would be possible to use a procedure instead of a
function, or to use a global variable rather than pass any parameter to
the sorting function, but let's assume that that would not be acceptable
in this assignment.)

Is my understanding correct, or is there some way to avoid having to use
two arrays?

g.




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~1998-12-02  0:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-11-27  0:00 Beginner's question (array parameters to functions) greg
1998-11-28  0:00 ` Matthew Heaney
1998-11-28  0:00   ` Brian Rogoff
1998-11-29  0:00     ` Matthew Heaney
1998-11-29  0:00   ` Fergus Henderson
1998-11-29  0:00     ` Matthew Heaney
1998-12-02  0:00       ` Fergus Henderson
1998-11-28  0:00 ` Tom Moran

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