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,21960280f1d61e84 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!s48g2000cws.googlegroups.com!not-for-mail From: "Ludovic Brenta" Newsgroups: comp.lang.ada Subject: Re: How come Ada isn't more popular? Date: 6 Feb 2007 03:01:41 -0800 Organization: http://groups.google.com Message-ID: <1170759701.876485.217200@s48g2000cws.googlegroups.com> References: <1169531612.200010.153120@38g2000cwa.googlegroups.com> <1169588206.234714.312650@k78g2000cwa.googlegroups.com> <1169624573.534128.172610@s48g2000cws.googlegroups.com> <87sle0sv9o.fsf@ludovic-brenta.org> <5rigs215675tlmql11ens5idv0188eqrut@4ax.com> NNTP-Posting-Host: 212.190.145.10 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1170759716 14167 127.0.0.1 (6 Feb 2007 11:01:56 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 6 Feb 2007 11:01:56 +0000 (UTC) In-Reply-To: <5rigs215675tlmql11ens5idv0188eqrut@4ax.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 SEVPXS01 Complaints-To: groups-abuse@google.com Injection-Info: s48g2000cws.googlegroups.com; posting-host=212.190.145.10; posting-account=ZjNXewwAAADyBPkwI57_UcX8yKfXWOss Xref: g2news2.google.com comp.lang.ada:9019 Date: 2007-02-06T03:01:41-08:00 List-Id: On Feb 6, 10:54 am, Dave Thompson wrote: > On Wed, 24 Jan 2007 09:07:15 +0100, Ludovic Brenta wrote: [snip] >> (*) consider that when we increment the address by one, it then >> references the next byte; whereas if we increment the pointer by one, >> it points to the next "unsigned long", i.e. 2, 4 or 8 bytes and not 1 >> byte further. C makes no distinction between addresses and pointers, >> lacking expressiveness in a crucial area. > > Wrong. C, even before C89, does know about pointer targets (strides). > Only _very_ early, Bell-Labs-only, pre-K&R1 C that was still in > transition from B had pointer === integer. Wrong? I think we're in agreement here. I was explaining that a pointer is not the same thing as an address, since incrementing a pointer gives a different result (next object) than incrementing an address (next byte). In C, address arithmetic is implemented in terms of char* and size_t only because sizeof(char) == 1; I think that's a hack. In contrast, address arithmetic in Ada is in terms of System.Address and Storage_Offset, which is much more explicit. > > When calling the subprogram, we get: > > > Set_Bit_In_Register (At_Address => To_Address (16#DEADBEEF#)); > > (optionally) > > > versus > > > set_bit_in_register (0xDEADBEEF); > > The type mismatch is a constraint violation (which must be diagnosed) > if the prototype declaration (or definition) is visible, and undefined > behavior (~ Ada erroneous, but occurring in many more places, hence > not necessarily diagnosed) if not. You _must_ cast: > set_bit_in_register ( (/*volatile*/unsigned long *) 0xDEADBEEF ); > or (better?) ... ( (my_reg_addr_typedef) 0xDEADBEEF ); So 0xDEADBEEF is an int, and there is no implicit conversion to unsigned long*. Is that what you're saying? OK, now I see my knowledge of C is fading away... > (assuming ulong aligned 3 mod 4 even works on your platform ) yeah, let's ignore that :-) Thanks for your comments. -- Ludovic Brenta.