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.2 required=5.0 tests=BAYES_00,FROM_WORDY, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fd3a5ba6349a6060 X-Google-Attributes: gid103376,public From: "Nick Roberts" Subject: Re: should I be interested in ada? Date: 1999/02/19 Message-ID: <7akvao$j5t$2@plug.news.pipex.net>#1/1 X-Deja-AN: 446252439 References: <7a72e6$g55$1@probity.mcc.ac.uk> <36C93BB4.1429@ecs.soton.ac.uk> <7afc1o$3mi$2@plug.news.pipex.net> <7afttr$7v3$1@nnrp1.dejanews.com> <7aganu$qsc$1@plug.news.pipex.net> <36CC3AEA.59E2@lanl.gov> <7ai502$6an$1@nnrp1.dejanews.com> <36CD8DBA.237C@lanl.gov> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Organization: UUNET WorldCom server (post doesn't reflect views of UUNET WorldCom) Newsgroups: comp.lang.ada Date: 1999-02-19T00:00:00+00:00 List-Id: William Clodius wrote in message <36CD8DBA.237C@lanl.gov>... |Perhaps the best simple example is the FORALL statement to do a |reordering of elements | |FORALL (I=1:N) X(J(I)) = X(I) | |which in Ada would require the explicit creation of a temporary to hold |the value of X, assignment to the temporary, and then the assignment of |the temporary to X. Note it is required that the values of J(1:N) not |duplicate one another and lie within the dimensioned ranges of X. This is a simple example, granted. But, it can be done without undue difficulty in Ada by declaring an appropriate procedure: procedure Reorder (Object: in out Vector; Index: in Selection) is Temp: constant Vector := Object; begin for i in Index'Range loop Object(Index(i)) := Temp(i); end loop; end; and perhaps adding: pragma Inline(Reorder); and then making the call: Reorder(X,J); You've got to declare a utility procedure, certainly, but otherwise this is just as neat as the Fortran, surely? More so, perhaps? And it will not necessarily produce object code which is any less efficient than the Fortran equivalent. The basic principle is that there is no Fortran 90 construct which cannot be modelled, perfectly adequately, by an Ada abstraction (typically a procedure or function). Furthermore, you get something extra in making that abstraction: encapsulation (factoring out common code), and a degree of self-documentation (the name of the subprogram says what it does). ------------------------------------- Nick Roberts -------------------------------------