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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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: g2news1.google.com!postnews.google.com!w19g2000yqa.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? Date: Mon, 7 Feb 2011 01:05:20 -0800 (PST) Organization: http://groups.google.com Message-ID: <544076dc-3357-4d8d-bfeb-7ae46a88b931@w19g2000yqa.googlegroups.com> 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> NNTP-Posting-Host: 137.138.182.236 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1297069520 6659 127.0.0.1 (7 Feb 2011 09:05:20 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 7 Feb 2011 09:05:20 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: w19g2000yqa.googlegroups.com; posting-host=137.138.182.236; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:16918 Date: 2011-02-07T01:05:20-08:00 List-Id: On Feb 7, 9:38=A0am, "Dmitry A. Kazakov" wrote: > > Scalar arguments are passed by copy, so whether they are immutable or > > mutable within the function is independent on their origin (and the > > original is not affected by this in any way). > > Unless, of course, you have meant something else. > > Exactly this. Passing mode (by copy vs. by reference) has nothing to do > with the mutability contract. Unchanged origin is no argument, because th= e > contract is broken [*]. The contract is not broken. The function cannot modify the original value that is passed by copy (this being the very nature of "copy") and the caller cannot even reason about what happens behind the signature. For example: void foo(int i); and then: int i =3D 5; foo(i); The i at the caller side cannot be modified and the caller is isolated from foo's internals. For the sake of argument, foo might be even written in... Ada. And for the sake of argument you can assume that this: void foo(int i) { // implementation goes here } is equivalent to this: procedure Foo (I : in Integer) is Local_Copy_Of_I : Integer :=3D I; begin -- implementation in terms of Local_Copy_Of_I goes here end Foo; So, no, the contract is not broken. Unless, of course, you have meant something else. -- Maciej Sobczak * http://www.inspirel.com