comp.lang.ada
 help / color / mirror / Atom feed
From: greg <ref15@columbia.edu>
Subject: Beginner's question (array parameters to functions)
Date: 1998/11/27
Date: 1998-11-27T00:00:00+00:00	[thread overview]
Message-ID: <365F4360.F7E85C1E@columbia.edu> (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.




             reply	other threads:[~1998-11-27  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-27  0:00 greg [this message]
1998-11-28  0:00 ` Beginner's question (array parameters to functions) 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
replies disabled

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