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,5430b81ad265fc75 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-15 19:17:15 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: Array Of Constant Strings? Date: 15 Apr 2003 19:17:14 -0700 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0304151817.7182ecd8@posting.google.com> References: <19guh-2f4.ln1@beastie.ix.netcom.com> <3E4D46B9.6060805@acm.org> NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1050459435 3236 127.0.0.1 (16 Apr 2003 02:17:15 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 16 Apr 2003 02:17:15 GMT Xref: archiver1.google.com comp.lang.ada:36176 Date: 2003-04-16T02:17:15+00:00 List-Id: Georg Bauhaus wrote in message news:... > > Will you collect a few impressions students have of the > readability of Ada programs? (As this might add more substance to > the argument that Ada syntax has advantages.) Well, here's one case where the C syntax is much simpler. In order to declare an array of strings in C, all I have to do is: const char* sa[] = { "now", "is", "the", "time" }; To do the equivalent in Ada, I'd have to do this: type String_Constant_Access is access constant String; type String_Array is array (Positive range <>) of String_Constant_Access; Now_String : aliased constant String := "now"; Is_String : aliased constant String := "is"; The_String : aliased constant String := "the"; Time_String : aliased constant String := "time"; SA : constant String_Array := (Now_String'Access, Is_String'Access, The_String'Access, Time_String'Access); Tucker showed this on CLA once: SA : constant String_Array := (new String'("now"), new String'("is"), new String'("the"), new String'("time")); Since all the string literals have static values, then no heap is really allocated. But this is really a compiler optimization -- I don't know whether you can really depend on it.