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,c9d5fc258548b22a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? Date: Mon, 07 Feb 2011 09:31:22 +0100 Organization: Tidorum Ltd Message-ID: <8r9ouqFselU1@mid.individual.net> References: <67063a5b-f588-45ea-bf22-ca4ba0196ee6@l11g2000yqb.googlegroups.com> <31c357bd-c8dc-4583-a454-86d9c579e5f4@m13g2000yqb.googlegroups.com> <05a3673e-fb97-449c-94ed-1139eb085c32@x1g2000yqb.googlegroups.com> <8r86vgFc3uU1@mid.individual.net> <19fh1chm74f9.11cws0j5bckze.dlg@40tude.net> <5d9bd120-4953-4fb1-a890-27267245e954@8g2000prt.googlegroups.com> <883b7161-15ee-4874-95bb-2e0273dab51d@y36g2000pra.googlegroups.com> <8r9iboFkfvU1@mid.individual.net> <14246472-9488-488a-8720-77b85b91707c@d23g2000prj.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net Q3ZhYtXndCRrS6rBWXz4DAIWGEu+F951Sy9ObiPcUeiTOssDF0 Cancel-Lock: sha1:fhOfvw248R0nU/h4G1XDHjFKu5E= User-Agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100328) In-Reply-To: <14246472-9488-488a-8720-77b85b91707c@d23g2000prj.googlegroups.com> Xref: g2news1.google.com comp.lang.ada:16915 Date: 2011-02-07T09:31:22+01:00 List-Id: Shark8 wrote: > On Feb 6, 11:38 pm, Niklas Holsti > wrote: >> The constraints can be removed by "casting away" the "constant" >> quality. > > If you can alter the constant via casting it is not truly a constant; > this is regardless of what any standard says.* That is a HORRID > idea, I for one, would NOT like it if my assertion "Denominator /= 0" > suddenly became "Denominator /= 3." This is just "unchecked programming", also possible in Ada using address clauses or address-to-access conversions. You get what you ask for. The C cast syntax (being similar to safe kinds of type conversions) makes it a bit hard to find such naughty tricks. The newer C++ standards have a wider choice of cast operators that make it easier, perhaps as easy as in Ada. > *In some languages a "constant" [rather literal] was a label/pointer > to the location which held the value thereof and one could therefore > "change the value of '4'" with some dirty-tricks/black-magic. A former colleague of mine spent a considerable time debugging a FORTRAN IV program's wrong results before he found that a COMMON area contained, in order, a one-dimensional array and a variable that was supposed to hold the value of pi, as set up at program start. An assignment to the array with an index that was too large had changed "pi" to something else, with unfortunate consequences for later trigonometric calculations. Unless your Ada program uses hardware (MMU) protection for its memory-resident constants you can change the "constants" through accesses that you get from address-to-access conversions. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .