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-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!news.albasani.net!not-for-mail From: "Frank J. Lhota" Newsgroups: comp.lang.ada Subject: Re: Learning Ada Date: Mon, 06 Jul 2009 18:43:45 -0400 Organization: albasani.net Message-ID: References: <59O1m.404661$4m1.69194@bgtnsc05-news.ops.worldnet.att.net> Reply-To: FrankLho.NOSPAM@rcn.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net fofVK6axgl7ERHwtGooe5R9gFX4BzLxiHtjUUSce3Pql0TRw+KohII8ePJBGPFqTPRZmCFEx6I+MBvsXjmhLcrKYB0Wn3nOQfxeBjtRvhB/p98zKCRyMiPUMkP7cScA4 X-Complaints-To: abuse@albasani.net NNTP-Posting-Date: Mon, 6 Jul 2009 22:43:51 +0000 (UTC) X-User-ID: ZsRa/TmEcs5L6UfQlCiTXBIylg4At8ryD8YLkm5dD8Y= In-Reply-To: Cancel-Lock: sha1:fT7zH5jvsWLr67x0bZpVZvs1Tcg= User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) X-NNTP-Posting-Host: ByQyKPFKHJbtUqMqj2ATASJBGs0kOmg++sC5sEJGyGI= Xref: g2news2.google.com comp.lang.ada:6870 Date: 2009-07-06T18:43:45-04:00 List-Id: anon wrote: > Yes, I did redefine apart of Standard. Found this out back in the mid 1990 > while testing GNAT 3.0x for a number of projects. Its also, one way (not the > best, but it is quick) of porting code from a 32-bit system down to a 16 or > 8 bit system. Like using Intel Core i7 system to write code for an Intel > 8086 system, which can use the same basic (non-protective mode) > instruction set. No, you did not re-define a part of Standard. Keep in mind that all of the compilation units you write is enclosed in the Standard package. As a result, every Ada name can be expanded to something of the form "Standard.*". When you wrote the package Standard as presented above, what you really did was add a package named Standard *within* the pre-defined package Standard, i.e. the result was something like this: -- Ada LRM Standard package Standard is ... type Integer is range ...; ... -- Your Standard package package Standard is type INTEGER is range - 2 ** 63 .. ( 2 ** 63 ) - 1 ; end Standard; end Standard; In other words, you've created the new type Standard.Standard.Integer, which is a separate type from Standard.Integer. > Also, rewriting any Ada package is allowable within the scope of the RM > (in some implementation it maybe required). And if I add a body for the > Standard package and uncommented the an operators I could of made the > operator do what I wanted it to do. Like having all Boolean operators > return FALSE. LRM A.2 (4) specifically prohibit the compilation of a child of package Ada in standard mode. I believe that some implementations would squawk if you tried to replace parts of System, especially since doing so could break other pre-defined units. > This process does not hide the built-in Standard package, its still there for > the system to handle the other types, such as the Character or > Wide_Character set, which can be a headache to define. Well, it does create some confusion. I would definitely *not* recommend naming a unit Standard. > > In , AdaMagica writes: >> Oh my dear anon, you are so wrong again. >> >>> package STANDARD is >>> >>> =A0 -- The universal type universal_integer is predefined. =A0 >>> >>> =A0 type INTEGER is range - 2 ** 63 .. ( 2 ** 63 ) - 1 ; >>> >>> end STANDARD; >> You do *not* redefine Standard with this declaration, you simply hide >> it. >> >> with Standard; >> >> procedure Temp is -- Here you will get into troubled water. >> >> X: Integer; -- this is still the integer from the predefined >> package Standard >> Y: STANDARD.Integer; -- this is your INTEGER >> >> use Standard; >> >> Z: Integer :=3D 2; -- oh lord, what's this now? >> >> -- I'm not sure and I'm reluctant to do the RM exegesis to find out. >> I *guess* it's your INTEGER; >> >> I: Integer :=3D Z**3; -- subtype of 3 is still the Integer defined in >> -- the predefined Standard you've hidden >> J: Integer :=3D Z**Z; -- This should then be illegal because the >> subtype of the right operand of ** >> -- must be the one from the hidden Standard. >> >> end Temp; >> >> Point is: You cannot redefine Standard! Full stop. >> >> I invite you to find the relevant paragraphs in the RM which state >> what will happen when you define a package named Standard. >> >> And please be careful to not mix up a subtype and the type of the >> subtype and the type of numeric literals. They are all different. > -- "All things extant in this world, Gods of Heaven, gods of Earth, Let everything be as it should be; Thus shall it be!" - Magical chant from "Magical Shopping Arcade Abenobashi" "Drizzle, Drazzle, Drozzle, Drome, Time for this one to come home!" - Mr. Wizard from "Tooter Turtle"