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,1116ece181be1aea X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-06 06:03:14 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Counter-proposal for variable arrays Date: Mon, 06 Oct 2003 15:12:29 +0200 Message-ID: <19p2ovk1jh4krn2h5cql44p37ovf6va99i@4ax.com> References: <834clb.uan1.ln@skymaster> <3F79EF18.7060600@comcast.net> <3F7B1076.8060106@comcast.net> <5mknnv4u96qqudrt4bd8n4t1cljp2fjlp8@4ax.com> <1065215180.95094@master.nyc.kbcfp.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1065445392 16311821 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:304 Date: 2003-10-06T15:12:29+02:00 List-Id: On Sun, 05 Oct 2003 05:52:06 GMT, Hyman Rosen wrote: >Dmitry A. Kazakov wrote: >> Pointer arithmetics is not yet an array. > >No. But an array is an array. What are you talking about? Mmm I guess array is something that one can pass as a parameter. For example: void Erase (char X [20]) { memset (X, 0, sizeof (X)); // How many element will be set? } >> an array of class-wide elements forces use of all sorts of pointers. > >Yeah. So what? What exactly would the implementation of an array of >class-wide elements look like, anyway? For example: -- This is not Ada, Syntax is imaginary. type Window is tagged ...; type Child_Window is new Window with ...; type Pop_Up_Window is new Child_Window with ...; type Container (From, To : Tag) is array (Integer range <>) of Window'Class (From..To); Wild_Array : Container (1..20); -- Compile error, not constrained Children_And_Pop_Up_Array : Container ( 1..20, -- Constrain the bounds From => Child_Window'Tag, -- Constrain the elements To => Pop_Up_Window'Tag ); -- This is OK The array contains 20 elements of types between Child_Window and Pop_Up_Window. Note that because all possible types are known, the upper bound of the element size is also known. So the array could be allocated as usual. Observe, that this is in full conformance with notorious Ada's concept of unconstrained types. You can have them, but all instances have to be constrained. Thus nothing prevents us from having an array of class-wide elements, IF there were a way to constrain both the array bounds (we already have this in Ada) and the elements (we do not have this). My proposal is to allow discriminants for array to have a way to constrain array elements. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de