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,38c827f7e800d317 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-06 18:09:58 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: aek@vib.usr.pu.ru (Alexander Kopilovitch) Newsgroups: comp.lang.ada Subject: Re: conversion Date: 6 Jul 2003 18:09:57 -0700 Organization: http://groups.google.com/ Message-ID: References: <3EFCC18B.4040904@attbi.com> <3F079D10.2060709@attbi.com> NNTP-Posting-Host: 195.242.19.243 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1057540197 2662 127.0.0.1 (7 Jul 2003 01:09:57 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 7 Jul 2003 01:09:57 GMT Xref: archiver1.google.com comp.lang.ada:40092 Date: 2003-07-07T01:09:57+00:00 List-Id: Robert I. Eachus wrote: >But notice two major differences between the Ada way, and the C and >Pascal way. The Ada solutions are built around standard Ada features, >not special case features, I do not see major difference between C and Ada general approaches to strings (Pascal is another matter). In both C and Ada strings are no more than regular arrays of characters - in core language, and all support for them is in standard library only. The particular difference between C and Ada regarding literals in a string array initializer is then simply a consequence of C's array/pointer kinship. >procedure Varying is -- an example of how to create ragged arrays in Ada. > > subtype Lim_Int is Integer range 0..30; > type Inner(L: Lim_Int := 0) is record S: String(1..L); end record; > type Wrapper is record I: Inner; end record; > type Ragged_Array is array (Integer range <>) of Wrapper; > > function "+" (S: in String) return Wrapper is > begin return (I =>(S'Length, S)); end "+"; > > function "+" (W: in Wrapper) return String is > begin return W.I.S; end "+"; Just interesting detail: you use the same name "+" for both conversions. (I do not argue against that, I simply found that somehow symptomatic.) > Dishes: Ragged_Array := (+"black pudding", > +"crab soup", > +"steak & kidney pie", > +"lemon tart"); > > Titles: Ragged_Array := (+"Quizionary", > +"Nose To Nose", > +"Myself", > +"General Dissent", > +"Veteran's Opinion", > +"Corporate Science Weekly", > +"Truth, Wealth, Health", > +"Bribery Times"); > >begin null; end Varying; As you may expect, I'm not satisfied with two things here: 1) Lim_Int - why 30, why not 123 ? Why should I always bother myself with justification of this value, and then, at the end, sooner or later, invite something like Ariane 5 effect (hopefully, in much lesser scale -;) ? 2) "+" at the beginning of each string literal. It reads as "Warning! This programming language does not pay particular attention to strings, you will be often obliged to do manually some common things with the strings". First point is certainly minor, because I can use Unbounded_String here. But the second point is quite significant. Just compare the situation with richness of representations for literals for numeric types in Ada. Alexander Kopilovitch aek@vib.usr.pu.ru Saint-Petersburg Russia