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-Thread: 103376,cd703a96ca51de6e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!elnk-atl-nf1!newsfeed.earthlink.net!stamper.news.atl.earthlink.net!newsread3.news.atl.earthlink.net.POSTED!14bb18d8!not-for-mail Sender: Matthew Heaney@MHEANEYIBMT43 Newsgroups: comp.lang.ada Subject: Re: 'Base References: <1134055303.758950.308680@o13g2000cwo.googlegroups.com> <2038690.eAzdaEvAON@linux1.krischik.com> <1134160956.403383.29180@z14g2000cwz.googlegroups.com> From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 10 Dec 2005 03:30:54 GMT NNTP-Posting-Host: 24.149.57.125 X-Complaints-To: abuse@earthlink.net X-Trace: newsread3.news.atl.earthlink.net 1134185454 24.149.57.125 (Fri, 09 Dec 2005 19:30:54 PST) NNTP-Posting-Date: Fri, 09 Dec 2005 19:30:54 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: g2news1.google.com comp.lang.ada:6805 Date: 2005-12-10T03:30:54+00:00 List-Id: ada_student@yahoo.com writes: > Indefinite subtypes cannot be allowed under any circumstances. I don't understand. What is type String? > It sounds like a hack just inorder to allow one class of array object > declarations into the language. I would hardly call being able to declare strings of different lengths a hack! > How can a statically typed language allow a type whose size is not known at > compile time? There's a "dope vector" associated with string objects, that describes the length and bounds of the string. > The Java array type certainly wins over Ada in this regard. But array objects in Ada can be declared on the stack. This allows you do things like: procedure Op1 (N : Natural) is S : String (1 .. N); begin procedure Op2 (S : String) is S2 : String := S; begin In neither case is heap necessary. You can do this sort of thing with tagged types too: procedure Op (O : T'Class) is O2 : T'Class := O; begin One nice feature is that if you do allocate an object whose type is class-wide, then you can initialize the object the same as in the example above: type T_Class_Access is access T'Class; procedure Op2 (O : T'Class) is O2 : constant T_Class_Access := new T'Class'(O); begin This is built into the language; you don't need a dispatching clone method.