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!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!130.59.10.21.MISMATCH!kanaga.switch.ch!news-zh.switch.ch!switch.ch!news.hispeed.ch!linux2.krischik.com!news From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: 'Base Date: Sat, 10 Dec 2005 08:52:45 +0100 Organization: Cablecom Newsserver Message-ID: <1170126.PvJVGQkA4J@linux1.krischik.com> References: <1134055303.758950.308680@o13g2000cwo.googlegroups.com> <2038690.eAzdaEvAON@linux1.krischik.com> <1134160956.403383.29180@z14g2000cwz.googlegroups.com> NNTP-Posting-Host: 84-73-0-2.dclient.hispeed.ch Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.hispeed.ch 1134202502 20536 84.73.0.2 (10 Dec 2005 08:15:02 GMT) X-Complaints-To: news@hispeed.ch NNTP-Posting-Date: Sat, 10 Dec 2005 08:15:02 +0000 (UTC) User-Agent: KNode/0.9.2 Xref: g2news1.google.com comp.lang.ada:6810 Date: 2005-12-10T08:52:45+01:00 List-Id: ada_student@yahoo.com wrote: > Indefinite subtypes cannot be allowed under any circumstances. > It sounds like a hack just inorder to allow one class of array > object declarations into the language. No at all. Ada is a higher level language then C/C++ or Java. It allows for better abstraction which is closer to real live. In real live arrays seldom beginn with zero: Weekdays 1 .. 7 Month 1 .. 31 Year 1 .. 366 Ada allows integer and array type for all those circumstances. > How can a statically typed language allow a type whose size is not > known at compile time? Quite easily. The size is just calculated at run time and the memory needed is then allocated staticly, on stack or on heap. The actual size becomes part of the array itself. In lower level languages this tedious work is dumped onto the programmer. > The Java array type certainly wins over Ada in this regard. Really? How about: type Historic_Data is array (-6000 .. 2005) of Data_Entry; Java (and C/C++) only have zero based arrays. In my eye that allway looses over abritary array bound. "Off by one error" is a well known term in those languages. To represent an Ada array in Java you would need: class Array_Type { private int First; private int Last; private Data Elements []; Data get_Element (int Index) { if (Index > First) then throw .... if (Index < Last) then throw .... return Data [Index - First]; } } Ada arrays are not a primitive type - they are a quite complex and powerfull type. Performace? Ada allways outperform Java for a start. But Ada's build in checks will also outperform C/C++ when used with all appropriate "assert()"s in place. For details on why read: http://en.wikibooks.org/wiki/Computer_programming/Error_handling http://en.wikibooks.org/wiki/Ada_Programming/Error_handling Especially chapter 5 on "Design by Contract". Martin -- mailto://krischik@users.sourceforge.net Ada programming at: http://ada.krischik.com