Xref: utzoo comp.lang.c++:6547 comp.object:971 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: PL/1 yes, and also Cobol (?) Message-ID: <1643@aber-cs.UUCP> Date: 18 Feb 90 19:05:55 GMT Reply-To: pcg@cs.aber.ac.uk (Piercarlo Grandi) Organization: Dept of CS, UCW Aberystwyth (Disclaimer: my statements are purely personal) Lines: 34 In article <12029@goofy.megatest.UUCP> djones@megatest.UUCP (Dave Jones) writes: > allowed to use composition with nameless members, or if a member could > be identified by any unambiguous path to it, like in PL/1. Did PL/1 do that? It's been so long since I used that language -- over fifteen years I guess -- I've forgotten most everything about it. PL/1 has been ragged so hard over the years, it seems strange to hear one of its features mentioned in a positive way. I seem to remember that also Cobol allows you to name a member with the shortest unique path to it. This feature may be seen as dangerous, as it means that modifying a data structure can make a program ambiguous, but this is really unavoidable, with inheritance as well. I had written in my C++ coding guidelines to prefix all identifiers used in a function with their scope operators. Somebody observed that this also should extend to members (prefixing them from the name of the class from which they are inherited), obviously not just to improve readability (where is this member from?), but also to guard against hazardous ambiguities caused by extending member lists in the future. As to PL/1, it actually had some *good* ideas, and some ridiculous ones (exceptions as a datatype!, 22/7 resulting in overflow,...). For example areas, based pointers, controlled storage. Not that I think they were all appropriate at the language level; for example, controlled storage is done in GNU LIB C++ as the obstack class, and areas can be done in C++ 2.0 with operator new overloading. On the other hand I would really be happy to see based (relative) pointer support, which is vital to get position independent data structures (and no, "smart pointers" are not a full solution). -- 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