home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.misc
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!saimiri.primate.wisc.edu!caen!hellgate.utah.edu!lanl!cochiti.lanl.gov!jlg
- From: jlg@cochiti.lanl.gov (J. Giles)
- Subject: Re: Pointers
- Message-ID: <1992Nov13.224022.16170@newshost.lanl.gov>
- Sender: news@newshost.lanl.gov
- Organization: Los Alamos National Laboratory
- References: <1992Nov5.014143.15635@newshost.lanl.gov> <id.6HVU.OC@ferranti.com> <1992Nov12.200950.8846@newshost.lanl.gov> <Bxnqv5.J71@mentor.cc.purdue.edu>
- Date: Fri, 13 Nov 1992 22:40:22 GMT
- Lines: 41
-
- In article <Bxnqv5.J71@mentor.cc.purdue.edu>, hrubin@pop.stat.purdue.edu (Herman Rubin) writes:
- |> [...]
- |> Why do some people find it necessary to hide simple devices under
- |> interfaces? The insistence on the use of these interfaces is like
- |> the joke about the mathematician who pours the water out of the bucket
- |> and turns off the stove to reduce the problem to the previous case.
-
- Why do some people want to hide simple devices under a mountain of
- confusing implementation detail? It's like those ugly buildings
- from a few years back where all the girders, cables, and vent ducts
- were deliberately left exposed. Bletch.
-
- Yes, there are simple devices like `sets' whose operations are
- insert an element, delete an element, test for membership, union
- and intersection of pairs of sets, set difference, etc.. When
- don't use an interface, then the code will be filled with linked
- lists, pointers, loops, etc. - or whatever implementation technique
- you chose to use. This means that you can't see whether you've
- *really* got sets at all!! For all you know, some part of that
- mess of detail misuses the access protocol appropriate to sets
- and is generating wrong, but plausible results. Further, if you
- decide to alter your implementation of sets to use bit strings
- or hash tables instead, you must change your *whole* code and
- not just the interfaces. Bletch.
-
- The same goes for all other structured data types. Yes, you *can*
- implement arrays by doing all the address arithmetic yourself:
- explicitly. No sane programmer would do so except as a last
- resort for optimization purposes. Such optimizations would be
- carried out as careful transformations of the high-level construct,
- not rewrites at the low-level. You write most of your array
- computations using the high-level interface in order to 1) have
- a better chance of writing correct code and 2) to allow the
- compiler to take advantage of known properties of arrays to
- optimize better (like, no two parts of the same array are
- aliased to one another - something you *don't* necessarily
- know if you've messed around with raw address calculations
- yourself).
-
- --
- J. Giles
-