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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news1.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!cyclone1.gnilink.net!gnilink.net!wn14feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: Learning Ada Reply-To: anon@anon.org (anon) References: <59O1m.404661$4m1.69194@bgtnsc05-news.ops.worldnet.att.net> <62792744-daca-437b-bdee-4b8a21f7ce27@j32g2000yqh.googlegroups.com> <82oq45tj2uu26u6ecsgq70bsjskr9dvghr@4ax.com> <878wj61bpo.fsf_-_@nbi.dk> <4a4f6cce$0$31869$9b4e6d93@newsspool3.arcor-online.net> <4Aa4m.421894$4m1.207252@bgtnsc05-news.ops.worldnet.att.net> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Mon, 06 Jul 2009 02:50:20 GMT NNTP-Posting-Host: 12.64.54.187 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1246848620 12.64.54.187 (Mon, 06 Jul 2009 02:50:20 GMT) NNTP-Posting-Date: Mon, 06 Jul 2009 02:50:20 GMT Organization: AT&T Worldnet Xref: g2news2.google.com comp.lang.ada:6848 Date: 2009-07-06T02:50:20+00:00 List-Id: Wrong! -- -- Just to show how easy it is redefining an Integer. Or the -- Standard package. Compiled with GNAT < 2010 -- with Ada.Text_IO ; with Standard ; -- require for redefining Standard package procedure Temp is use Ada.Text_IO ; begin declare package Integer_IO is new Ada.Text_IO.Integer_IO ( Integer ) ; use Integer_IO ; begin New_Line ; Put_line ( "Integer predefined limits" ) ; Put ( "Range => ( " ) ; Put ( Integer'First ) ; Put ( " .. " ) ; Put ( Integer'Last ) ; Put_Line ( " ) " ) ; New_Line ; end ; -- -- Now redefine the type Integer. -- declare type Integer is range -2 ** 8 .. 2 ** 8 - 1 ; package Integer_IO is new Ada.Text_IO.Integer_IO ( Integer ) ; use Integer_IO ; begin New_Line ; Put_line ( "Integer redefined limits" ) ; Put ( "Range => ( " ) ; Put ( Integer'First ) ; Put ( " .. " ) ; Put ( Integer'Last ) ; Put_Line ( " ) " ) ; New_Line ; end ; -- -- Using a new Standard package -- declare package Integer_IO is new Ada.Text_IO.Integer_IO ( Standard.Integer ) ; use Integer_IO ; begin New_Line ; Put_line ( "Integer limits from a new Standard package" ) ; Put ( "Range => ( " ) ; Put ( Standard.Integer'First ) ; Put ( " .. " ) ; Put ( Standard.Integer'Last ) ; Put_Line ( " ) " ) ; New_Line ; end ; end Temp ; -- -- This will compile under current GNAT < 2010. Package cut down -- because the complete version is too long and is not needed to -- make the point. But all other types and operations will fall back to -- GNAT built-in Standard package aka for GNAT its universal Standard -- package. -- package STANDARD is -- The universal type universal_integer is predefined. type INTEGER is range - 2 ** 63 .. ( 2 ** 63 ) - 1 ; end STANDARD ; In , Albrecht =?ISO-8859-1?Q?K=E4fer?= writes: >anon schrieb: >> But some people like "Ludovic Brenta, state that most Ada programmers >> would prefer to create their own types. In some case, that goes against the RM >> because it can create a non-standardize form of an Ada programs, that violate >> other RM rules. > >It would be really smashing if you could provide some sort of proof for >this bold claim. > >> Plus, the RM states that a number of numeric types are >> predefined, such as "Integer", and it subtypes "Natural" and "Positive" as >> well the type "Float" and its subtypes. >> Redefining those predefines types are >> legal in Ada, by simply re-defining the type. > >.... no? Standard.Integer et al cannot be redefined. You can change the >underlying compiler, but then you could also change "begin" to "start". > >> Like for example, using 24 bit integer: >> >> type Integer is range -2 ** 24 .. +2 ** ( 24 - 1 ) ; >> >> To use this new definition of "Integer", globally it needs to be define in the >> standard package, > >Now how would you go around doing that? > >> but for a single package or routine it better to create a new >> type or subtype and for the routine or package. But in most programming this >> is not necessary. That is, since Ada creation and the DOD dropping it full >> support of Ada, the usage for redefining the numeric data types is almost nil, >> not the norm any more. Plus, the DOD require full documentation on all new >> define types. > >Why should we care about what the DoD requires again? > >> Now, "Rob Solomon" stated that he think "it would be beneficial, if >> the types Float and Integer were removed from the language". > >That is a personal opinion, not a law of nature. > >> Second, the predefined types allow for the program to be more portable, >> because a users type might not be accepted on the new system. But using the >> standards or creating a subtype from the standards is better. An example is: >> >> type Integer is range -2 ** 256 .. +2 ** ( 256 - 1 ) ; >> >> which is a valid Ada statement but in a 32-bit and most 64-bit system this >> type is not allowed. > >There's nothing stopping you from creating a special Ada compiler >supporting arbitrary-length integers. > > >Albrecht