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-Thread: 103376,dc1fff2721602dfa X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.66.82.137 with SMTP id i9mr1967385pay.41.1359724826159; Fri, 01 Feb 2013 05:20:26 -0800 (PST) Path: s9ni27998pbb.0!nntp.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Ada and string literals References: <4978d638-a04b-4561-85e9-cf6620265af2@googlegroups.com> Date: Fri, 01 Feb 2013 08:20:24 -0500 Message-ID: <85wqus1887.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (windows-nt) Cancel-Lock: sha1:GBU4H//38WPt0MZauIVboAFeuVA= MIME-Version: 1.0 X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: f2c04510bc119c55ab71402872 X-Received-Bytes: 1812 Content-Type: text/plain Date: 2013-02-01T08:20:24-05:00 List-Id: Robert A Duff writes: > Suppose you want an array of strings. Well, you can't have > one in Ada, except in the unusual case where they all happen > to have the same length. So you use array of access to string. > > Colors : constant String_Sequence := > ("red"'Access, -- This is not Ada! > "orange"'Access, > "dark green"'Access, > ...); > > That gets pretty tedious if you declare a name for each color. That's what "+" is for: function "+" (Item : in String) return access constant String is begin return new String'(Item); end "+"; Colors : constant String_Sequence := (+"red", -- This _is_ Ada! +"orange", +"dark green", ...); I would be _very_ nice if that definition of "+" was in Ada.Strings somewhere. Of course, if you also want the non-constant equivalent: function "+" (Item : in String) return access String then can you have ambiguity problems. -- -- Stephe