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: a07f3367d7,caabf5265fad78e5 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Mon, 29 Jun 2009 12:25:14 +0200 From: Georg Bauhaus User-Agent: Thunderbird 2.0.0.22 (Macintosh/20090605) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: unsigned type References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Message-ID: <4a48968a$0$31863$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 29 Jun 2009 12:25:14 CEST NNTP-Posting-Host: 364cfc92.newsspool3.arcor-online.net X-Trace: DXC=G4fcY<idWTBl_ X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:6706 Date: 2009-06-29T12:25:14+02:00 List-Id: anon schrieb: > For Strings: > -- 'A' is a zero length string, A'Last = 0, and > -- put_line ( A ( A'First .. A'Last ) ) ; > -- does not raise an Constraint_Error even though in > -- this case it translate to: > -- put_line ( A ( 0 .. 0 ) ) ; > A : String := "" ; > > Since you can have zero length string , the index is Natual instead of Positive, > because zero is in Natural but is not define in Positive. Even though the > Standard package define String index as a Positive type. (GNAT) (It is slightly confusing, I think, to say that in a definition like type String is array (Positive range <>) of Character; the index type is Natural. It's not Natural in the Ada sense; that fact that many String related subprograms use the Natural subtype emphasizes the presence of Natural in String handling, but does not turn subtype Positive into index type Natural, does it?) > Always use standards, those who do not are the one making the mistakes > that others must correct to make the program portable during updating. How is it possible for _any_ implementation defined type to be portable just because the standard says it is implementation defined? (Like Standard.Integer?) For example, the GNU Ada Database Environment uses a 64 bit type available with GNAT. This type may well be impossible when using other compilers. type SQLBIGINT is range -(2 ** 63) .. +(2 ** 63) - 1; for SQLBIGINT'Size use 64; How will a subtype of Long_Long_Integer be different? Long_Long_Integer may not be provided at all. Or it does not have 64 bits. I don't see how to gain anything with subtyping or deriving from the predefined integer types in cases such as this one. Using a subtype, there is more opportunity for shooting yourself in the foot when you use them where you should have been using database integers. A more striking example has been outlined by Tom Moran. Any Ada compiler can immediately decide whether or not this library unit can be translated (ported) when it sees SQLBIGINT. Seems perfectly clear, uses standard conforming type definitions, and explicitly stating what is needed. Wouldn't this be much more implicit and more diffuse if the developers had tried to force database integers to be standard integers?