Xref: utzoo comp.lang.c++:6546 comp.object:970 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!mcsun!ukc!dcl-cs!aber-cs!pcg From: pcg@aber-cs.UUCP (Piercarlo Grandi) Newsgroups: comp.lang.c++,comp.object Subject: Re: Inheritance vs. Composition Summary: in a *computer* only contiguity and pointers. Message-ID: <1642@aber-cs.UUCP> Date: 18 Feb 90 18:54:25 GMT Reply-To: pcg@cs.aber.ac.uk (Piercarlo Grandi) Organization: Dept of CS, UCW Aberystwyth (Disclaimer: my statements are purely personal) Lines: 54 In article <20020@bellcore.bellcore.com> sjs@bellcore.com Switzer) writes: Dave Jones (djones@megatest.UUCP) writes: > From article , > by pcg@rupert.cs.aber.ac.uk (Piercarlo Grandi): > > > ... [ to ] map the concepts ultimately onto contiguity or > > pointers (the only ways we have in a computer to indicate a > > relationship between data). > > That's what this all comes down to isn't it? That and what kind of > shorthand-resolution you want the compiler to do for you. (Not easy > questions, actually.) I was meaning to comment on this earlier, but I let it pass. There are many ways to represent relationships in a computer. I beg to differ. In a *computer* you have memory as a block of storage units, and composite entities can only be built out of contiguity or pointers. C++ is a language that tries hard to let you do *implementation* level work, that is "full unrestricted" access to the underlying hardware. The type constructors in C++, and other machine oriented HLLs, are records and arrays for heterogenous and homogeneous contiguity, and pointers. For instance, relational databases (conceptually) use an associative technique based on the equality of attribute values. Another associative technique is pattern matching (grep, and X resource databases). Other types of reference relationships might include inter-addressing-environment references, file references, and persistent-object store references. But these are all *program* level abstractions. One of the big tasks of programming is to map all the useful data structuring abstractions you have (and these are usually content based) onto contiguity and pointers. An especially hard job because contiguity is bad for dynamic resizing and pointers by their very nature are one way only, and this has many profound consequences (e.g. on garbage collection) in all the common cases where you have many-to-many abstractions to represent (just think that essentially network databases are there only to give you bidirectional pointers). It is notable about C++ is that BS has carefully designed it to retain by and large (the two notable exceptions being constructors/destructors and multiple virtual inheritance) the MOHLL flavour of C. Eiffel for example, not to speak of CLOS or Simula 67, do not have this aim. What I find disagreeable about virtual multiple inheritance (I also don't like much constructors destructors, incidentally) is that what you think is an object is actually implemented as a graph (tree) of subobjects. This may well be too high level. It is my impression that thsi is because of prefixing. -- Piercarlo "Peter" Grandi | ARPA: pcg%cs.aber.ac.uk@nsfnet-relay.ac.uk Dept of CS, UCW Aberystwyth | UUCP: ...!mcvax!ukc!aber-cs!pcg Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk