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,9ca52c8981c1b86a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!feeder.news-service.com!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.ada Subject: Re: One other possible reason for the C predominance Date: Tue, 22 Mar 2011 13:19:01 -0700 Organization: None to speak of Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx01.eternal-september.org; posting-host="mytEQcPL+ceHcrnNa7VoaQ"; logging-data="14713"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rHXFRh+j0ln0w9mQcXu6g" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:wjTHTbyvC/s4FoBLn2Fb1OZn0Fo= sha1:dGEx7sb/LzjdgElYAM4BJ2ur/V4= Xref: g2news2.google.com comp.lang.ada:19356 Date: 2011-03-22T13:19:01-07:00 List-Id: Ludovic Brenta writes: [...] > In fact, C is bad because it assumes a uniform memory architecture and > a flat address space. These assumptions were OK for a few decades but > nowadays, GPUs with dedicated memory are a common case of non-uniform > memory architectures; the Cell processor and the rise of massively > parallel supercomputers is another. Ada has storage pools to > represent this kind of thing. [...] No, C doesn't assume this. C provides arithmetic on pointers. If p is a pointer and i is an integer, then you have: p + i -> p i + p -> p p - i -> p p - p -> i (Note that the result is the number of pointed-to objects, not the number of bytes.) C also provides comparison operations on pointers; p0 < p1 means that p0 points to a lower memory address than p1 does. But all of these operations have undefined behavior if the two pointers don't point into the same object (or, as a special case, just past the end of the object.) Since the behavior is undefined, an implementation could even check for out-of-bounds accesses, though most don't do so. For C implementations on systems with a flat address space, all this tends to work as you'd expect (and it makes it very easy to shoot yourself in the foot by accidentally going outside the bounds of the object you're working with). But it's entirely possible to implement C on a system where distinct objects exist in distinct address spaces. This is by deliberate design. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Nokia "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"