comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: One other possible reason for the C predominance
Date: Tue, 22 Mar 2011 17:54:37 -0400
Date: 2011-03-22T17:54:37-04:00	[thread overview]
Message-ID: <wccpqpilt2a.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: ln62radi2y.fsf@nuthaus.mib.org

Keith Thompson <kst-u@mib.org> writes:
> Ludovic Brenta <ludovic@ludovic-brenta.org> writes:
>> In fact, C is bad because it assumes a uniform memory architecture and
>> a flat address space. ...

> No, C doesn't assume this.

Right.  Some C programmers assume it, either by accident or on purpose.
I don't remember K&R C well enough to know whether K and/or R assumed
it.  But the C standard does not assume it.

...
> 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.

A C impl could, but it's somewhere between difficult and impossible to
do it efficiently.

> 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.

Well, sort of.  C programmers on 8086 found it necessary to sprinkle
their programs with "near" and "far" all over the place -- which means
those programs weren't C.

>... This is by deliberate design.

Deliberate design by whom?  K&R, or later C-standards committees?

- Bob



  reply	other threads:[~2011-03-22 21:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-21 22:36 One other possible reason for the C predominance Yannick Duchêne (Hibou57)
2011-03-22 13:09 ` Ludovic Brenta
2011-03-22 14:05   ` Yannick Duchêne (Hibou57)
2011-03-22 15:12     ` Ludovic Brenta
2011-03-22 15:36       ` Yannick Duchêne (Hibou57)
2011-03-22 20:19       ` Keith Thompson
2011-03-22 21:54         ` Robert A Duff [this message]
2011-03-22 14:56 ` Hoàng Đình Long
2011-03-22 15:06 ` Hoàng Đình Long
     [not found] ` <4af234a8-2294-4e0e-a741-ea7dced2ae62@b22g2000prb.googlegroups.com>
2011-03-22 15:34   ` Yannick Duchêne (Hibou57)
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox