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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5037bf0bb33408c8,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-08 03:58:00 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!129.240.148.23!uio.no!ntnu.no!not-for-mail From: Preben Randhol Newsgroups: comp.lang.ada Subject: "&" for array versus "&" for Strings Date: Tue, 8 Oct 2002 10:57:59 +0000 (UTC) Organization: Norwegian university of science and technology Message-ID: NNTP-Posting-Host: kiuk0152.chembio.ntnu.no X-Trace: tyfon.itea.ntnu.no 1034074679 22718 129.241.83.78 (8 Oct 2002 10:57:59 GMT) X-Complaints-To: usenet@itea.ntnu.no NNTP-Posting-Date: Tue, 8 Oct 2002 10:57:59 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:29581 Date: 2002-10-08T10:57:59+00:00 List-Id: According to the ARM 4.5.3: 3. The concatenation operators & are predefined for every nonlimited, one-dimensional array type T with component type C. They have the following specifications: 4. function "&"(Left : T; Right : T) return T function "&"(Left : T; Right : C) return T function "&"(Left : C; Right : T) return T function "&"(Left : C; Right : C) return T If I use this in this way: ------------------------------------------------------------------ with Ada.Text_IO; use Ada.Text_IO; procedure Array_Test is type Name_Array is array (Positive range <>) of String (1..6); procedure Print_Names (Names : Name_Array) is begin for No in Names'First .. Names'Last loop Put_Line (Integer'Image(No) & ": " & Names (No)); end loop; end; begin Print_Names ("Ada " & "Babbel"); end Array_Test; ------------------------------------------------------------------ Then the result becomes: 1: A 2: d 3: a 4: 5: 6: 7: B 8: a 9: b 10: b 11: e 12: l Why is this happening. If I do : Print_Names ("Ada " & "Babbel" & "Odin "); gnatmake array_test.adb gnatgcc -c array_test.adb array_test.adb:15:26: ambiguous operand for concatenation array_test.adb:15:26: possible interpretation at line 4 array_test.adb:15:26: possible interpretation in package Standard gnatmake: "array_test.adb" compilation error which is expected. and Print_Names ("Ada Babbel"); gnatmake array_test.adb gnatgcc -c array_test.adb array_test.adb:15:17: expected type "Name_Array" defined at line 4 array_test.adb:15:17: found a string type gnatmake: "array_test.adb" compilation error which is also expected. -- Ada95 is good for you. http://libre.act-europe.fr/Software_Matters/02-C_pitfalls.pdf