simulating data abstraction facilities

John Woods, Software john at frog.UUCP
Wed Jul 2 03:13:14 AEST 1986


> What I would like to do is to simulate data abstraction
> facilities as a design guideline. Note, for various
> reasons we HAVE to use C for time being. The draft-proposal
> is to use file scoping and conditional preprocessor
> clauses to stop private members of a class of data/functions/types
> from external linkage.
> 

I have bad news for you.  This will not simulate data abstraction.

This will _be_ data abstraction.

Unless, of course, you use the phrase "Data Abstraction (TM)" in the way
that people who do research into it do, where you MUST be wrapped in
compiler provided straight jackets and given a crayon to hold in your teeth
with which to write.  But this approach (discipline added to an existing
language) was what was used when I took "6.170 Software Engineering" at MIT,
from Barbara Liskov (of CLU fame):  we used a garden-variety PL/1 compiler
with some stylistic rigor to provide protected data types, because the CLU
compiler hadn't been finished yet.

(And in my opinion, from having to work with the CLU compiler itself a couple
of years later, it was easier to do it in PL/1, because (A) the CLU compiler
still does not prevent programming mistakes, just certain classes of them,
and (B) the CLU compiler prevents certain reasonable programming constructs,
just simply because they didn't occur to the compiler designers.

After all, look at fopen() and friends in the standard C library -- when was
the last time you ripped the top off a FILE * to look inside it (that is, if
you aren't a UCB or Bell Labs programmer [*])?

* Some notable programs from each of these caused me to have to rewrite a
from-scratch stdio library that otherwise worked perfectly well (even better
than the original in many respects) to use a structure that was similar to
the regular FILE structure, with much anguish being added to preserve the
old (improved) functionality while making sure that the structure fields
were manipulated the same way that these excremential programs expected!).

--
John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101
...!decvax!frog!john, ...!mit-eddie!jfw, jfw%mit-ccc at MIT-XX.ARPA

"Imagine if every Thursday your shoes exploded if you tied them the usual way.
This happens to us all the time with computers, and nobody thinks of
complaining."
			Jeff Raskin, interviewed in Doctor Dobb's Journal



More information about the Comp.lang.c mailing list