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/18 Message-ID: <7ahkn0$kab$1@plug.news.pipex.net>#1/1 X-Deja-AN: 445766109 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> <36CC11A1.C7A71642@hercii.mar.lmco.com> 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-18T00:00:00+00:00 List-Id: Jerry Petrey wrote in message <36CC11A1.C7A71642@hercii.mar.lmco.com>... [...] |> Fortran's array facilities as an example, in Fortran one can put: |> |> real, dimension (1:10) :: x |> ... |> x = 1.0 |> |> setting all the elements of x to 1.0 (a 'broadcast scalar'), whereas in Ada |> to do the same thing, you must code something like: |> |> X: array (1..10) of Float; |> ... |> for i in X'Range loop X(i) := 1.0; end loop; | | |I think using an aggregate would be much better than a loop: | |X := (1 .. 10 => 1.0); Precisely right, of course. Also, Fortran's 'index vector' feature, e.g.: x = 0.0 x( (/ 2, 7, 1, 4, 9 /) ) = b+0.5 can sometimes be directly emulated fairly easily by an Ada aggregate: X := (2|7|1|4|9 => B+0.5, others => 0.0); and any other index vector operations, e.g.: x( (/ 2, 7, 1, 4, 9 /) ) = x( (/ 8, 10, 3, 5, 6 /) ) can be easily done in Ada, using one or two utility procedures or functions, e.g.: type Selection is array (Positive range <>) of Integer; ... function Extract (V: in Vector; S: in Selection) return Vector is Result: Vector(S'Range); begin for i in S'Range loop Result(i) := V(S(i)); end loop; return Result; end; procedure Insert (Object: in out Vector; Which: in Selection; Value: in Vector) is begin for i in Which'Range loop Object(Which(i)) := Value(i); end loop; end; and then a call such as: Insert(X, (2, 7, 1, 4, 9), Extract(X, (8, 10, 3, 5, 6))); Having built your 'helper' functions and procedures, there really is nothing in Fortran that cannot be done almost as easily (and as, or almost as, efficiently) in Ada. My examples have been in terms of array facilities, but the principle applies to everything else in Fortran. So, hopefully, my original point stands. ------------------------------------- Nick Roberts 'The time has come,' the Walrus said, 'To talk of many things: Of shoes--of ships--and sealing wax-- Of cabbages--and kings-- And why the sea is boiling hot-- And whether pigs have wings.' Lewis Carroll "Through the Looking Glass" -------------------------------------