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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,1116ece181be1aea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-02 12:48:34 PST Path: archiver1.google.com!news2.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wn14feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!rwcrnsc52.ops.asp.att.net.POSTED!not-for-mail Message-ID: <3F7C810E.7070100@comcast.net> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Is the Writing on the Wall for Ada? References: <3F739C1D.4030907@attbi.com> <3F78E850.8010401@comcast.net> <3F797748.3000203@noplace.com> <834clb.uan1.ln@skymaster> <3F79EF18.7060600@comcast.net> <3F7B1076.8060106@comcast.net> <5mknnv4u96qqudrt4bd8n4t1cljp2fjlp8@4ax.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 24.34.139.183 X-Complaints-To: abuse@comcast.net X-Trace: rwcrnsc52.ops.asp.att.net 1065124111 24.34.139.183 (Thu, 02 Oct 2003 19:48:31 GMT) NNTP-Posting-Date: Thu, 02 Oct 2003 19:48:31 GMT Organization: Comcast Online Date: Thu, 02 Oct 2003 19:48:31 GMT Xref: archiver1.google.com comp.lang.ada:131 Date: 2003-10-02T19:48:31+00:00 List-Id: Dmitry A. Kazakov wrote: > Which only means that there is a deficiency in array design. They > have to be allowed to have discriminants... You can't have thought about this. Ada does allow Multidimensional arrays, arrays of arrays, and ragged arrays. But they are different, and viv� la difference. I could even create an ISAM type in Ada, but why bother, ragged arrays are usually better. The point is though that all of these structures have structure invariants which are different. An array is a structure where all the elements are alike. Ada lets you play games by "hiding" properties of elemental types to get this alikeness. You can have arrays of types with discriminants, but if you do, all the elements in an array have the same discriminant. If you want an array of elements with different discriminants, the type with the discriminant has to be buried: type Color is (Red, Orange, Yellow, Green, Blue, Violet); type Colored_Record (Col: Color := Red) is ...; type Outer_Record is record CR: Colored_Record; end record; type Green_Array is array(Integer range <>) of Colored_Record(Green); type Technicolor_Array is array(Integer range <>) of Outer_Record; GA: Green_Array(1..10); TA: Technicolor_Array(1..10); ... if GA(7).Col = GA(6).Col -- must be true if TA(7).CR.Col = TA(6).CR.Col -- may or may not be true. You may think it would be "nice" to be able to create arrays in Ada where the elements are of different size, or different lengths, or have different ranges. But they wouldn't be arrays. If you wanted to add a reserved word fwallop to name such a structure, the semantic sugar to support declarations of such collections would obviously be pretty trivial. But again, why bother. Ada has a nice invariant--all elements of an array have the same visible attributes--and a way to wrap up objects to hide attributes from arrays if you want to allow them to be different. -- Robert I. Eachus "Quality is the Buddha. Quality is scientific reality. Quality is the goal of Art. It remains to work these concepts into a practical, down-to-earth context, and for this there is nothing more practical or down-to-earth than what I have been talking about all along...the repair of an old motorcycle." -- from Zen and the Art of Motorcycle Maintenance by Robert Pirsig