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!postnews.google.com!d28g2000yqc.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? Date: Mon, 7 Feb 2011 05:56:21 -0800 (PST) Organization: http://groups.google.com Message-ID: <737a6396-72bd-4a1e-8895-7d50f287960e@d28g2000yqc.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> <4d4ff70e$0$6886$9b4e6d93@newsspool2.arcor-online.net> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1297086982 31889 127.0.0.1 (7 Feb 2011 13:56:22 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 7 Feb 2011 13:56:22 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d28g2000yqc.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: g2news1.google.com comp.lang.ada:16926 Date: 2011-02-07T05:56:21-08:00 List-Id: Georg Bauhaus wrote on comp.lang.ada: > In C, if you write > > int foo(const int arg) { arg = 3; } > > you will get a compile time error. I know. So? The point is that the "const" was absent in the function I had to debug, and had been absent for about 15 years. Also, not a lot libX11 or Motif functions have "const" arguments. This bad style had a lot of influence on the programmers of 15 years ago whose code I must now maintain. In Ada, this bad style is simply not possible. In Ada, "in" really means "in". > If you write > > int foo(const int* arg) { *arg = 3; } > > you will get a compile time error. I know but bugs are easier to detect because when reviewers see a pointer argument, they know they have to look out for writes through the pointer. Even if the pointer is to a "const", since it is trivially easy to defeat the const-ness. > For further ammunition for Verdun style language comparisons, > see function Ada.Numerics.Discrete_Random.Random. What does that mean? > I think there are better arguments. No. There was an old (because difficult to reproduce) bug. I spent time finding and correcting it. This bug could not have happened in Ada. This argument is the only relevant one to me. -- Ludovic Brenta.