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,f868292008c639ce X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Java vs. Ada - strings (was: C vs. Ada - strings) Date: 2000/06/03 Message-ID: <39394E0B.75BD479C@telepath.com>#1/1 X-Deja-AN: 630696967 Content-Transfer-Encoding: 7bit References: <390F0D93.F835FAD9@ftw.rsc.raytheon.com> <8en5o9$ihe$1@nnrp1.deja.com> <8eonos$e70$1@wanadoo.fr> <1fIU4.4668$Rx3.250161@typhoon.nyroc.rr.com> <3924B730.AFB52C1C@acenet.com.au> X-Accept-Language: en,pdf Content-Type: text/plain; charset=us-ascii X-Complaints-To: Abuse Role , We Care X-Trace: newshog.newsread.com 960056518 216.14.8.56 (Sat, 03 Jun 2000 14:21:58 EDT) Organization: Telepath Systems (telepath.com) MIME-Version: 1.0 NNTP-Posting-Date: Sat, 03 Jun 2000 14:21:58 EDT Newsgroups: comp.lang.ada Date: 2000-06-03T00:00:00+00:00 List-Id: Pete wrote: > I see your point. But suppose in Java, I have > Srting ar[] = new String[] { "have", "a", "good", "day" }; > // assume some processing. > ar[2] = "junk"; > > I think the Ada way to do this would be much more complicated. I may be > wrong, can this be done so simply in Ada *without having to create new > types, or making function calls*? If so, I am interested in seeing how to do > this. You are asking if you can create an object of a new type in Ada without creating a new type? Of course not. But that's pretty much equivalent to type String_Ptr is access String; type String_List is array (Natural range <>) of String_Ptr; AR : constant String_List := (new String'("have"), new String'("a"), new String'("good"), new String'("day")); ...without function calls. Although what your aversion to function calls buys you is beyond me. One could easily create a custom type for ragged string arrays perhaps using "and" as a constructor, which would clean this up to: AR : constant Ragged_String_Array := "have" and "a" and "good" and "day"; This would also allow you to combine catenated strings and string arrays in one expression into this type of construction AR : constant Ragged_String_Array := "have" and Integer'image(Some_Var) & " straight" and "good" and "days"; Which I believe would look a bit uglier in Java due to lack of a catenation operator. I've never done this myself because in 11 years of Ada work I've never had a much need for ragged string arrays. That's probably why Ada doesn't come with a type for them. :-) -- T.E.D. Home - mailto:dennison@telepath.com Work - mailto:dennison@ssd.fsi.com WWW - http://www.telepath.com/dennison/Ted/TED.html ICQ - 10545591