From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,998965b11075593f X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: Beginner's question (array parameters to functions) Date: 1998/11/29 Message-ID: #1/1 X-Deja-AN: 416649102 Sender: matt@mheaney.ni.net References: <365F4360.F7E85C1E@columbia.edu> NNTP-Posting-Date: Sat, 28 Nov 1998 18:22:46 PDT Newsgroups: comp.lang.ada Date: 1998-11-29T00:00:00+00:00 List-Id: Brian Rogoff writes: > On Sat, 28 Nov 1998, Matthew Heaney wrote: > > greg writes: > > ... array sorting question snipped ... > > > > But there are two arrays no matter what: one is unsorted, and one is > > sorted. Having two arrays is a condition of the problem statement, and > > has nothing to do with the language. > > The problem statement said nothing about whether the sort modified the > original array or not. Ada doesn't specify whether arrays are passed by > reference; if you want to do a sort in place and return the same array > then you'll use access types (pointers if you speak C) and work with > references to the array. I consider it an excellent feature of Ada that > there is no extra syntax for this, unlike C. The problem was: "implement a sort routine as a function, that takes an unsorted array as the parameter, and returns a sorted array as a result." Something like: function Sort (Items : Item_Array) return Item_Array; This problem requires two arrays. It may be that "the problem statement said nothing about whether the sort modified the original array or not," but the implicit requirement for a pair of arrays is derived from the explicit requirement that the sort be implemented as a function.