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,85ee038f08622eb8 X-Google-Attributes: gid103376,public From: cosc19z5@Bayou.UH.EDU (Spasmo) Subject: Re: Array Literals? Date: 1996/08/13 Message-ID: <4uquru$jrq@Masala.CC.UH.EDU>#1/1 X-Deja-AN: 173994365 references: <4uo9b6$qj1@Masala.CC.UH.EDU> <4uq1jb$gpu@newsbf02.news.aol.com> organization: University of Houston newsgroups: comp.lang.ada Date: 1996-08-13T00:00:00+00:00 List-Id: John Herro (johnherro@aol.com) wrote: : cosc19z5@Bayou.UH.EDU (Spasmo) asks if the : following will work with any standard Ada compiler: : > type Int_Array is array(Integer range <>) of Integer; : > procedure Print_Int_Array ( I_List : Int_Array ); : > Print_Int_Array ( (1, 2, 3, 4) ); : Surely! That's standard Ada. But there's one caution. In your : simple example, there's only one procedure called Print_Int_Array, and : thus, when the compiler sees the call, it knows that the aggregate : (1,2,3,4) must be of type Int_Array, and there's no problem. If you had : had several overloaded procedures with that name, each taking a different : type, and if the aggregate (1,2,3,4) would fit more than one of those : types, then your call would be ambiguous and wouldn't compile. In that : case, you would have to *qualify* the aggregate, thus: : Print_Int_Array(Int_Array'(1,2,3,4)); Makes plenty of sense. : Note the ' with the ( ). Sometimes, for clarity, it's a good idea to : qualify the aggregate anyway, so the reader will know what type (1,2,3,4) : is. Yep. Question though, what exactly is the difference between using Int_Array' ( ), and Int_Array ( )? I have used the latter before to perform conversion with no apparent ill effect, but I believe there is a difference, I just can't seem to recall it. : Without realizing it, you've been using "array literals for functions : and the like" whenever you've written a quoted string in a subprogram : call! For example, Put_Line("Hello"); is an abbreviation for : Put_Line(('H','e','l','l','o'));. Well yes I knew that string literals were a form of array literal, but some languages have special considerations for strings so that you could treat strings in certain ways that you may not be able to treat standard arrays. I just wasn't sure if Ada was in fact this consistent in its treatment (I'm glad to see it is). Thanks. : - John Herro : Software Innovations Technology : http://members.aol.com/AdaTutor : ftp://members.aol.com/AdaTutor : A: "PS/2 Microchannel, GPIB, and Greyhound." : Q: "Name two dogs and a bus." -- Spasmo "Everyone has secrets, but sometimes you get caught, So if it's just between us, my silence can be bought" "Blackmail" by Sloppy Seconds