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 Path: g2news2.google.com!postnews.google.com!e21g2000yqe.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? Date: Tue, 8 Feb 2011 02:43:56 -0800 (PST) Organization: http://groups.google.com Message-ID: <36f322c1-5dc4-427a-9a55-18ea4930f977@e21g2000yqe.googlegroups.com> References: <67063a5b-f588-45ea-bf22-ca4ba0196ee6@l11g2000yqb.googlegroups.com> <8r86vgFc3uU1@mid.individual.net> <19fh1chm74f9.11cws0j5bckze.dlg@40tude.net> <4d4ff70e$0$6886$9b4e6d93@newsspool2.arcor-online.net> <737a6396-72bd-4a1e-8895-7d50f287960e@d28g2000yqc.googlegroups.com> <4d5008a5$0$6879$9b4e6d93@newsspool2.arcor-online.net> <4d5031fe$0$6765$9b4e6d93@newsspool3.arcor-online.net> <1f229967-d3cf-42b6-8087-c97ee08652f3@i40g2000yqh.googlegroups.com> <4d5116d1$0$7657$9b4e6d93@newsspool1.arcor-online.net> <7c91bcbb-60f5-4630-b05d-1c36c85b7bb1@s11g2000yqh.googlegroups.com> <4d511c9d$0$7658$9b4e6d93@newsspool1.arcor-online.net> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1297161836 9805 127.0.0.1 (8 Feb 2011 10:43:56 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 8 Feb 2011 10:43:56 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e21g2000yqe.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.6) Gecko/2009012111 Red Hat/3.0.6-1.el5 Firefox/3.0.6,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:17952 Date: 2011-02-08T02:43:56-08:00 List-Id: Georg Bauhaus wrote on comp.lang.ada: > On 2/8/11 11:16 AM, Ludovic Brenta wrote: >>> Strict contracts in subprogram profiles. Ha! > >>> void foo2(int jump) >>> =A0 =A0 /* make sure jump % 2 =3D=3D 0! */ >>> { >>> =A0 =A0 =A0... >>> } > >>> Write that in Ada 2005 to demonstrate the glorious power of >>> your subtype constraints. =A0When was it that compilers will >>> support aspects reliably? > >> Easy: > >> procedure Foo2 (Jump : in Natural); >> -- Jumps by 2 * Jump > > > Thereby eliminating the very *possibility* that 2*jump can be odd! > > See how you couldn't provide a solution, but made up > a different case? No, I provided a proper contract that reflects the problem at hand rather than your fragile solution. =A0 Now > > =A0 =A0Foo2 (Jump =3D> Natural'Last); procedure Foo2 (Jump : in Natural) is begin if Jump <=3D Natural'Last / 2 then Baz (2 * Jump); else declare Half_Jump : constant Natural :=3D Jump / 2; Remainder : constant Natural :=3D Jump mod 2; begin Baz (2 * Half_Hump); Baz (2 * Half_Jump); if Remainder /=3D 0 then Baz (2 * Remainder); end if; end; end if; end Foo2; And that's assuming Long_Long_Integer is not wide enough for the calculations. -- Ludovic Brenta.