🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #1669

Re: C's sins of commission

#1669
From: David Chase
Date: Tue, 09 Oct 1990 17:50
30 lines
2182 bytes
skrenta@cbmvax.commodore.com (Rich Skrenta) writes:

>Suppose I eliminate pointers from my language and instead provide the
>programmer with high-level data structures such as lists and arrays.
>Won't he just use integer indexes as "pointers" into these data structures
>if he needs them?  Isn't this what typically happens in Pascal programs,
>where pointers are not as versatile as they are in C?  Are the programs
>any more readable ...

You're right, mostly, but you're missing one thing.  Pointers (as
implemented in C and C++) are generated by the programmer, either by
taking the address of something, or by allocating new memory.  In C,
C++, Pascal, Modula-2, BCPL, and PL/1, the programmer is responsible
for ensuring that whatever the pointer points to is not reused while
the pointer is in use.  Getting this wrong leads to messy bugs that
are not (necessarily) repeatable from machine to machine, or from
malloc version to malloc version.  

If integers in arrays are used instead of pointers, then the bug is at
least confined to an object of the same type (more or less --
sufficiently clever programming will produce more clever bugs), and
the bug is repeatable from machine to machine, and malloc version to
malloc version.  Hidden in this is the unfortunate fact that the
programmer may need to write his own allocator within the array.  In
practice, this is not been that big a problem for me, since these
little allocators deal in a fixed arena with uniform objects (unlike
malloc).  In practice, expandable arrays often suffice, and allow me
to make strong assertions about what bugs cannot exist in my code.

David
Technical Details
Message-ID: <1224@exodus.Eng.Sun.COM>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!know!sdd.hp.com!wuarchive!cs.utexas.edu!sun-barr!newstop!exodus!rbbb.Eng.Sun.COM!chased
References: <64618@lanl.gov) <2883@igloo.scum.com) <2171@enea.se> <1990Oct8.135551.21639@arnor.uucp> <14972@cbmvax.commodore.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!know!sdd.hp.com!wuarchive!cs.utexas.edu!sun-barr!newstop!exodus!rbbb.Eng.Sun.COM!chased
From: chased@rbbb.Eng.Sun.COM (David Chase)
Newsgroups: comp.lang.misc
Subject: Re: C's sins of commission
Message-ID: <1224@exodus.Eng.Sun.COM>
Date: 9 Oct 90 17:50:37 GMT
References: <64618@lanl.gov) <2883@igloo.scum.com) <2171@enea.se> <1990Oct8.135551.21639@arnor.uucp> <14972@cbmvax.commodore.com>
Sender: news@exodus.Eng.Sun.COM
Organization: Sun Microsystems, Mt. View, Ca.
Lines: 30