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,c63aa81a67eceb8f X-Google-Attributes: gid103376,public From: Hyman Rosen Subject: Re: Ragged Array Proposal Date: 1999/09/23 Message-ID: #1/1 X-Deja-AN: 528841843 Sender: hymie@calumny.jyacc.com References: <37e7c08e@eeyore.callnetuk.com> <7satei$e2q$1@nnrp1.deja.com> <37EA4E91.1D4D1FC@averstar.com> <37eaa24b@eeyore.callnetuk.com> Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@panix.com X-Trace: news.panix.com 938129514 29802 209.49.126.226 (23 Sep 1999 23:31:54 GMT) Organization: PANIX Public Access Internet and UNIX, NYC Mime-Version: 1.0 User-Agent: Gnus/5.070096 (Pterodactyl Gnus v0.96) Emacs/20.3 NNTP-Posting-Date: 23 Sep 1999 23:31:54 GMT Newsgroups: comp.lang.ada Date: 1999-09-23T23:31:54+00:00 List-Id: "Nick Roberts" writes: > Try telling a C++ programmer that, in Ada, they have to declare an access > type, and then repeat the "new String'("xyz")" incantation for every string, > just to declare an array of strings, and they might be likely to say "Ada? > No thanks, I'll stick to C++, if you don't mind." A C programmer, maybe. In C++, if you want to initialize one of the STL containers with constant data, you pretty much have to make copies of things. In C, we often do char *fruits[] = { "apple", "orange", "pear" }; The compiler does a bunch of accounting for us to make this possible. What we have really written above is the following: static char unique_apple[6] { 'a', 'p', 'p', 'l', 'e', 0 }; static char unique_orange[7] = { 'o', 'r', 'a', 'n', 'g', 'e', 0 }; static char unique_pear[5] = { 'p', 'e', 'a', 'r', 0 }; char *fruits[3] = { &unique_apple[0], &unique_orange[0], &unique_pear[0] }; Is it possible to do something similar in Ada? Something like (forgive my fractured pseudo-Ada syntax) - apple: aliased String(5) := "apple"; orange: aliased String(6) := "orange"; pear: aliased String(4) := "pear"; type StringPtr is access String(<>); fruits: StringPtr[1..3] := (apple'access, orange'access, pear'access);