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: a07f3367d7,c9d5fc258548b22a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!m16g2000prc.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? Date: Fri, 4 Feb 2011 13:36:29 -0800 (PST) Organization: http://groups.google.com Message-ID: <668153eb-f5b5-43c4-81f6-f013541d85c2@m16g2000prc.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> <4d4c232a$0$28967$882e7ee2@usenet-news.net> NNTP-Posting-Host: 174.28.151.164 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1296855390 8592 127.0.0.1 (4 Feb 2011 21:36:30 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 4 Feb 2011 21:36:30 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m16g2000prc.googlegroups.com; posting-host=174.28.151.164; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 ( .NET CLR 3.5.30729; .NET4.0E),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:16880 Date: 2011-02-04T13:36:29-08:00 List-Id: On Feb 4, 9:00=A0am, Hyman Rosen wrote: > You make two errors here. The first is to assume without > any actual knowledge that it is possible for the argument > to be a null pointer; As presented it is not possible to determine IF it is not possible to pass a null-pointer in; unlike Ada, C has no null exclusion and so cannot guarantee from the contract-that-is- the-parameter-list that to be the case -- He MUST reason it from the code itself making the argument dependent on the context in which it is used. {For example, it could be a part contained in a header-file whose original using-program DID have the impossibility of passing NULL, but if re-used then it may be the case that there is no such guarantee. > it is likely that the contract for > this procedure requires that it not be. The second is that > you test for the pointer being null each time through the > loop rather than just once. This is a deficiency, IMO, of C and somewhat even Pascal; In Ada, even w/o null-exclusion, we would likely say: Procedure Some_Procedure( Message : Access String ) is begin if Message /=3D Null then Declare S : String Renames Message.All; Begin For Index in S'Range loop -- whatever processing and display End Loop; End; end if; end Some_Procedure; And within the procedure itself we capture the context which would in the C-program and bind it directly to the procedure. This becomes trivial with a not null access parameter.