home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / object / 3223 < prev    next >
Encoding:
Text File  |  1992-08-16  |  29.4 KB  |  613 lines

  1. Newsgroups: comp.object
  2. Path: sparky!uunet!decwrl!csus.edu!netcom.com!objsys
  3. From: Bob Hathaway <objsys@netcom.com>
  4. Subject: Re: Type Conformance and Inheritance (was O.M() versus M(O) notation)
  5. Message-ID: <fb9mk5g.objsys@netcom.com>
  6. Date: Mon, 17 Aug 92 05:32:58 GMT
  7. Organization: Object Systems
  8. Summary: Very long Definitonal and Tutorial posting
  9. References: <1992Aug5.162329.22871@ucunix.san.uc.edu> <PCG.92Aug14170701@aberdb.aber.ac.uk>
  10. Lines: 601
  11.  
  12. [After writing this long-winded article I noticed other responces.  I'll
  13.  have to reply to them later.  This article is already over 600 lines.]
  14.  
  15. In article <PCG.92Aug14170701@aberdb.aber.ac.uk>, pcg@aber.ac.uk (Piercarlo Grandi) writes:
  16. > On 13 Aug 92 01:58:32 GMT, objsys@netcom.com (Bob Hathaway) said:
  17. >objsys> Type is well defined.
  18. >
  19. >Really? I see the word 'type' used with very different referents by
  20. >different people at different times. At some of these times I get a
  21. >strong suspicion that they themselves are not clear as to what they are
  22. >talking about.
  23.  
  24. This is entirely possible but I strongly believe the notion of type is
  25. easily justified.  I will use the term "abstract type" (as in Emerald
  26. and Jade) to try to be more precise.  I elaborate further on the nature
  27. and definition of type later in the posting.
  28.  
  29. >objsys> No mention is made of implementation since type systems only
  30. >objsys> deal with types.
  31. >
  32. >Hardly surprising! If 'type systems' were dealing with blondes, than
  33. >that would be news!
  34.  
  35. But this clearly shows type and implementation are separate!
  36.  
  37.   [Poor review of Kim and Lochovsky "OO Concepts, Databases and Applications"]
  38.  
  39. I think OO Concepts... is an excellent work although I view it as mostly of
  40. historical significance.  Won Kim's work and reputation in the database
  41. community and especially in the OODB domain is hardly equaled.  Your
  42. comments make no specific points so I'll consider them semantically worthless
  43. unless and or until justified.
  44.  
  45. >objsys> So "In the presence of dynamic binding it is (in general)
  46. >objsys> impossible to determine statically the class of a variable, but
  47. >objsys> with the appropriate type rules we can still perform
  48. >objsys> type-checking."
  49. >
  50. >Another lot of meaningless, self referential verbiage. One could rewrite
  51. >it as
  52. >
  53. >        "In the presence of type checking with deterministic type rules
  54. >        it is in general appropriate to perform..."
  55. >
  56. >or any other permutation of this fine collection of buzz words, and the
  57. >meaning would not change.
  58.  
  59. You must be a linguistic transformationalist!  Firstly and most required
  60. seems to be a reading of the Emerald papers, something I notoriously leave
  61. behind.  This paper describes abstract types and gives a clear description
  62. of them although I don't agree with all of their philosophy.  I [bragging on]
  63. stumbled across a similar notion of typing myself while considering a more
  64. powerful domain and believe/discovered it is also applicable in the more
  65. classical programming domain.  I later learned that this view of typing
  66. was actually quite common, confirming my suspicion that this separation
  67. is indeed desirable if not outright necessary.  [Bragging off]. 
  68.  
  69. I'll give a quick tutorial from the beginning, hopefully addressing all
  70. of the issues raised thus far.  I'm not going to give references since
  71. this is not a formal paper but any can be given if asked for.  I feel
  72. it is necessary to go over and define the basics before any constructive
  73. discussion can take place.  This will give a clear, precise, and
  74. complete definition of all terms I have discussed and advocated thus far
  75. which it is hoped will satisfy your up to now insatiable and much asked for
  76. desire for such things.  Please read the entire discussion before commenting
  77. on it in bits and pieces since examples are given after the discussion
  78. which should help clarify the meaning (after which please feel free
  79. to comment bitwise and piecewise).
  80.  
  81. First we have an abstract or real-world entity (which *can* be referred to
  82. as an abstract or real world entity).  Now we need a design/programming
  83. metaphor for them.  This requires a notation and within this notation this
  84. metaphor can be referred to as a type.  We'll use the term "abstract type"
  85. to help avoid confusion (although I prefer to use the term type).  Anyway
  86. this "abstract type" notation really just describes its analogous counterpart
  87. in some real-world or abstract-world domain (or classification scheme) and
  88. *only* that counterparts properties/attributes/etc.  An abstract type can
  89. also be thought of as a specification or interface or even protocol because
  90. it so specifies the properties/attributes/etc. of its counterpart.  These
  91. latter terms are often freely interchanged so they should not be used in
  92. isolation.  As shown below, abstract types and classes each call for a
  93. specification/interface/protocol.  Obviously an abstract or real world entity
  94. can have any number of types because types are simply a description of
  95. this entity.
  96.  
  97. Now some form of implementation must be specified.  It shall be given that
  98. multiple implementations should be available to satisfy an abstract type.
  99. This has been found to be an axiom since implementations (also called
  100. representations) are not fixed by the abstract type and because various
  101. implementations may be desirable under various conditions and at various
  102. times.  It is even highly desirable under very dynamic environmental
  103. conditions for implementations to decide to "become" other implementations,
  104. in other words for them to change their own representation.  Therefore some
  105. means of defining implementations is required.  Object constructors can be
  106. used in Emerald, the "class" construct is the means of specifying an
  107. implementation in most "classical" object-oriented languages, by definition;
  108. and objects are self-descriptive in prototyping languages.
  109.  
  110. I'll stay with the classical object-oriented languages for now and define
  111. "class" to be an implementation construct which is in accord with the
  112. available object-oriented literature.  Classes must then have a name or
  113. means of reference and also group the assorted implementation constructs
  114. to distinguish from among the infinite number of possible implementations.
  115. But classes can satisfy many types in a similar fashion that types can be
  116. satisfied by multiple implementations.  This is the basic subtyping or
  117. inclusion polymorphism rule and will be given as an axiom.  A brief
  118. explanation can begin with Smalltalk, a statically typeless language.
  119. Smalltalk has no way of stating (specifying) that certain operations or
  120. constraints are required by some instance (polymorphic parameter or
  121. object).  These should be included in an instance's type allowing multiple
  122. implementations and requiring inclusion polymorphism, or more simply put
  123. that an implementation can satisfy multiple types.  This requires the
  124. separation of abstract type from class, otherwise only one construct could
  125. be used as with classical object-oriented languages.
  126.  
  127. An interesting theoretical issue is the role of abstraction.  Abstract types
  128. are directly implemented by classes in real-world modeling since there are
  129. no high-level abstractions such as "device" in the real-world, it is simply
  130. a subjective classification and therefore I don't see the need for any
  131. inclusion polymorphism but only the need for multiple implementations in
  132. the RWM domain.  But in the abstract domains there is a great need for
  133. abstractions, such as "device", and it is given as a later example.
  134.  
  135. Now we have a clear notion of entity, abstract type, and class.  
  136.  
  137. Real or Abstract World entity:
  138.  
  139.   Our abstract concept of a stack 
  140.   or perhaps a stack of lunch trays (with a spring).
  141.  
  142. Abstract Type (one example, many per Real or Abstract World Entity):
  143.  
  144.   type Stack is
  145.     push(T)
  146.     pop() returns T
  147.   end
  148.  
  149. Implementations (two examples, many per Abstract type):
  150.  
  151. class List_Stack: private List is      class Array_Stack is
  152. public:
  153.   push(int) ...                          push(int) ...
  154.   pop() ... return (int) ...             pop() ... return (int) ...
  155. private:                               private:
  156.   ...                                     int    collection[100]
  157. end                                    end
  158.  
  159. and etc.  
  160.  
  161. Now reuse becomes an issue.  Inheritance and compositional approaches have
  162. been suggested for the reuse of implementations.  As in the first example,
  163. a class can be reused by inheriting from it.  An alternative is the
  164. compositional approach as advocated by Jade.  I don't have the paper with
  165. me but the basic idea is to allow finer grained reuse by making all
  166. constructs (at least from the level of method and object in Jade) available
  167. to programmers.  This can obviously be extended to all constructs but lets
  168. stay at this level and use an informal notation (not necessarily Jade) for
  169. simplicity.
  170.  
  171.   type Stack is
  172.     push(T)
  173.     pop() returns T
  174.   end
  175.  
  176. Environment (whats expected to be out there)
  177.   Array
  178.   top
  179. Component Array_Push(T element) is
  180.   Array[top++] = element;
  181. end
  182.   
  183. Environment
  184.   Array
  185.   top
  186. Component T Array_Pop() is
  187.   return Array[--top];
  188. end
  189.   
  190. Then a stack implementation can be defined as:
  191.  
  192. class Array_Stack is
  193.   push(T) <= Array_Push
  194.   T pop() <= Array_Pop
  195. end
  196.  
  197. If a queue is desired, Array_Push can be reused but pop will change:
  198.  
  199. Environment
  200.   Array
  201.   top
  202. Component T Array_Remove() is
  203.   ... // left to reader
  204. end
  205.  
  206.   class Array_Queue is
  207.     insert(T)  <= Array_Push
  208.     T remove() <= Array_Remove
  209.   end
  210.  
  211. A type should be declared for the new queue to be useful.  Perhaps even
  212. a constraint could be added to the type specifying it is indeed a queue,
  213. requiring all matching implementations to specify that they are a queue
  214. to avoid any accidental type mismatches such as an object that has an insert
  215. and remove operation but isn't really a queue.  This could be defined
  216. formally but I'll stay with an informal constraint for user simplicity.
  217. The Emerald approach is to define an operation such as queue_length making
  218. all implementations implement that operation, but this approach is
  219. arbitrary.
  220.  
  221.   type Queue is
  222.     insert(T) 
  223.     T remove()
  224.     Queue is a queue.
  225.   end
  226.  
  227. If an is_empty operation is needed (and the original interface must not
  228. change), Jade requires users to redefine the entire interface in a new
  229. type or class.  An alternative is to use inheritance (also called a
  230. "differential programming style") in which this addition alone is added
  231. in the new type or class, the rest is "inherited".  Thus inheritance reuses
  232. the entire interface unless some parts of it are dropped as is possible in
  233. Modula-3.  This is simpler although it requires the user to look at more
  234. than one interface since it is shared.  This is criticized by the Jade
  235. community because it seems to violate locality although it reduces the
  236. size of such derived interfaces; these are moot points.  Not sharing
  237. abstract type or even class interfaces can also cause problems due to
  238. redundancy, as discussed later.  Inheritance is also a way of implementing
  239. the is-a (or is-a-kind-of) relation as discussed below.  Many (in CS)
  240. criticize this use of inheritance from a philosophical point of view while
  241. others (in SE) praise it.  Another issue for reuse is an abstract class,
  242. as discussed below.  
  243.  
  244. The is-a relation by itself is very useful.  For example, devices have many
  245. properties.  These can be put together into a device abstract type giving
  246. the requirements for a class or abstract type to be a kind of device.  There
  247. are various kinds of devices: mechanical, biological, electrical, etc.  All
  248. of these kinds of devices share the properties of devices.  The entire
  249. device interface would have to be duplicated with only a purely
  250. compositional approach.  Inheritance saves the day by allowing abstract types
  251. (and classes where inheritance also applies) to inherit the entire interface
  252. from device.  If a device can do it, so can the various kinds of devices.  We
  253. could create abstract subtypes or subclasses if certain kinds of devices have
  254. a property and others don't or state that only some devices have the property;
  255. this isn't considered important here.  Inheritance is considered important for
  256. deep hierarchies since it would be undesirable to replicate parent interfaces
  257. all the way down.  With a purely compositional approach all implicit subclass
  258. interfaces would have to be changed if the interface of device were to change.
  259. This is caused by the redundancy required by the purely compositional approach
  260. which does not make the inheritance relation explicit and therefore does not
  261. make use of the sharing provided by traditional inheritance.
  262.  
  263. Abstract classes also have a place since they can help define object
  264. representations.  There are no "device" objects, the hierarchy would have
  265. to be traversed to near its leaves to come across an instantiable entity.
  266. However, inheritance can be used to define abstract classes which give
  267. partial implementations of classes.  Composition can also be used as
  268. above for a finer degree of reuse but abstract classes provide a more
  269. comprehensive facility.  They are much like abstract types but are used
  270. for implementation, not typing.
  271.  
  272. An interesting point is that there is no partial reuse of abstract types
  273. as there is with abstract classes.  If an abstract type is reused by name
  274. and certain parts are specified as being included and others are not,
  275. this is inheritance.
  276.  
  277. Another point is that inheritance is not necessarily hierarchical,
  278. it depends on your definition.  The is-a relation does not preclude
  279. graphs although some implementations of class inheritance do.  For
  280. instance, loops in an abstract type graph are trivially handled;
  281. they only require traversal once to determine the entire required
  282. interface (for lack of a better way of putting it).  A similar lack of
  283. this ability can be found in Ada and especially Modula since module
  284. definitions and package specifications must be hierarchical by decree
  285. and not by necessity.  I have complained about and debated this myself
  286. for years!  And as discussed in more detail below, abstract types
  287. do not have difficulty with graphs but classes do, actually confirming
  288. that combining abstract type and class together should be considered
  289. harmful!
  290.  
  291. Delegation also allows loops, it is hoped the system would track them
  292. with standard graph traversal algorithms although a little twist is
  293. encountered if the class objects could change during traversal (but this
  294. would be considered atypical).
  295.  
  296. So if a Description abstract type is a kind of Document and should contain
  297. all of Documents behaviour and a Document is a kind of Description and should
  298. contain all of Descriptions behavior, Document and Description should inherit
  299. from each other.  The fact that this can get into a recursive types
  300. entanglement with classes can actually be used as an argument for the
  301. separation of classes from abstract type, since this should be and is
  302. allowed with abstract types but is a mess with classes (their possible
  303. implementations)!
  304.  
  305. >* why have 'type' have as referent the formal specification of a
  306. >  mathematical entity and not the mathematical entity itself? You
  307. >  seem to be saying that 'type' Unsigned is not the algebra of modulo
  308. >  2^N naturals, but a formal specification of that algebra. There can be
  309. >  many different formal specifications for that algebra. Which one is
  310. >  meant by 'type' Unsigned?
  311.  
  312. "Type" is already used in design and programming languages where the term
  313. should be defined as above.  Abstract and real world entities should stand
  314. for themselves.  There is a stack and there are natural numbers and so
  315. their "type" (or abstract type if you wish) is a metaphor for them (actually
  316. they are a metaphor for them if you prefer this world;-).  This answers your
  317. next contention too, so it is elided.
  318.  
  319. >* If 'class' refers to the implementation of a 'type', does it refer to
  320. >  the interface or to the code behind that interface or to the
  321. >  assertions that decorate ? They are all 'implementation'! And if it
  322. >  refers to all of them at the same time, how can I distinguish between
  323. >  those orthogonal aspects? 
  324.  
  325. As discussed above.  Since there are multiple implementations for an
  326. abstract type there must be some construct and way of naming these
  327. implementations.  As for the reuse of them, I have covered both
  328. compositional and inheritance based approaches and it should be obvious
  329. that they are not mutually exclusive.
  330.  
  331. >objsys> Perhaps this is a clue to the solution of the age old proverb:
  332. >objsys>         Why not concrete data types?
  333. >objsys> Types can be viewed as abstract data types, and classes (or
  334. >objsys> whatever representational construct) can be viewed as concrete
  335. >objsys> ones!
  336. >
  337. >More meaningless/fuzzy verbiage...
  338.  
  339. Perhaps without the complete (and quite verbose) description above but
  340. since I have defined and justified all terminology from the beginning
  341. perhaps now you can appreciate the humor.  The above verbiage is not
  342. meaningless or fuzzy, it is funny:-)
  343.  
  344. >objsys> Perhaps we're confusing terminology;
  345. >
  346. >Ah, that's one of the few sure things in this discussion.
  347.  
  348. No longer...  If there are any unclear points where I have given imprecise
  349. definitions please point them out.  Any discussion, alternatives, and
  350. commentary is most welcome, too.
  351.  
  352. [On general definitional confusion]
  353.  
  354. I have defined all of the terms I have used so far; you are encouraged
  355. do the same if you disagree.  But having a single standard should be
  356. preferred.
  357.  
  358. >objsys> and Class (or whatever representational/implementation
  359. >objsys> device as appropriate) defines the concrete structure of an
  360. >objsys> object.
  361. >
  362. >So 'class' is only the structure of an object, not the implementation of
  363. >operations on it?
  364.  
  365. No, it is both.  Thanks for pointing out my incompleteness.
  366.  
  367. >But the compiler never sees any of 'type' and 'type system'! The
  368. >compiler only sees interfaces and implementations! Or, at best,
  369. >assertions that decorate them and are derived from specifications.
  370.  
  371. As a compiler writer I work with this all the time.  Compilers do have type
  372. checkers and they do enforce type-checking.  If not at compile-time then
  373. thru meta-objects (or thru an RTS) at run-time.  The abstract type as
  374. defined above is used exclusively for this purpose.  Classes (as defined)
  375. define an object's structure and behaviour and external interface to their
  376. world.  (Abstract) types therefore are used to insure that objects can
  377. satisfy the required operations as defined by the types they must satisfy.
  378. This is precisely ASU's definition.
  379.  
  380. >pcg> There is absolutely no reason to believe that structural reuse
  381. >pcg> opportunities need to happen in a hierarchical fashion like with
  382. >pcg> inheritance.
  383. >
  384. >objsys> Sure there is.  We do it all the time; its called
  385. >objsys> classification.
  386. >
  387. >Yes, but all hierarchical taxonomies are inappropriate, in the sense
  388. >that they always cause bad classifications. 
  389.  
  390. No, they don't.  As discussed under devices, they can be quite appropriate.
  391. And without an explicit inheritance relation there can be excessive
  392. redundancy.  Since I believe your next example is in error (although I
  393. did give an example where graphs are required), perhaps you could give
  394. a counter example in terms of the device hierarchy if you have the time.
  395. And as previously pointed out the is-a relation and inheritance does not
  396. have to be hierarchical, although it often satisfies that constraint.
  397.  
  398. >                        Just consider the Unix
  399. >filesystem; one is forced to choose between thse two organizations:
  400. >
  401. >        c_compiler/bin c_compiler/bin ada_compiler/man ada_compiler_man
  402. >        bin/c_compiler bin/ada_compiler man/c_compiler man/ada_compiler
  403. >
  404. >when neither is really appropriate; the man page for the ada compiler is
  405. >both a man page and part of the ada compiler package, and neither aspect
  406.                      ^^^^^^^
  407. You seem to be confusing aggregation (or composition) and inheritance.  The
  408. Ada man-page can be an instance of man-page and a member of the compiler
  409. package; nothing is wrong there.  This has nothing to do with a hierarchical
  410. abstract type or class taxonomy.  If you disapprove of them then you must
  411. give a relevant counter-example.
  412.  
  413. >prevails. Similarly in many data design instances. Hierarchical database
  414. >models have fallen from favour because they forced people to do data
  415. >designs that were strict taxonomies, that are inappropriate almost
  416. >always, except for 'parts explosion' situations.
  417.  
  418. I think your file system example is off entirely.  I'll contend directories
  419. are classes, subdirectories are subclasses, and files are instances of their
  420. containing directory.  Instances linked into several directories simply have
  421. several parents (piece of cake for me or prototyping systems).  Directories
  422. linked into more than one subdirectory also have several parents (multiple-
  423. nheritance and BSD).  Directory loops in the filesystem form non-hierarchical
  424. graphs in the class lattice (watch your recursive programs!).  Dynamic
  425. inheritance is the rule and delegation works as well since inheritance can
  426. be viewed as nothing more than structured delegation with cloning (or
  427. inversely put delegation can be not-so-elegantly viewed as reference parents).
  428. No lack of anything here...
  429.  
  430. >objsys> Once wants the ability (my favourite peeve) to independently
  431. >objsys> reuse interfaces, specifications, and implementations, and a
  432. >objsys> general purpose algebra for all of thse things.
  433. >
  434. >objsys> Some systems with inheritance may not provide this but I don't
  435. >objsys> see any inherent restrictions.
  436. >
  437. >Well, except that you insist otherwise that type systems should be
  438. >hierarchical. Isn't that a fairly large inherent restriction?
  439.  
  440. No I don't and never have.  As pointed out above, the is-a relation does
  441. not have a hierarchical restriction and indeed further justifies the
  442. separation of type and class.  I defended classification, not strict
  443. hierarchies.
  444.  
  445. >Here we are back to 'type' as 'abstract specification', not 'interface
  446. >specification'. 
  447.  
  448. No difference, these terms can be used interchangeably as discussed above.
  449. Since I have now defined abstract type and class perhaps any confusion
  450. will be reduced.
  451.  
  452. >Still, I am puzzled by your insistence that 'type'
  453. >should refer to the specification itself, and not the mathematical
  454. >entity described by the specification.
  455.  
  456. Actual entities stand for themselves - why give them another name?  And
  457. many abstract types are in fact truly abstract and are simply used for
  458. classification as discussed under inclusion polymorphism; they have no
  459. metaphor to match.  So it seems most natural to use the term "type" as a
  460. metaphor (actually vice-versa) for abstract and real world entities.
  461.  
  462. >objsys> class as an implementation construct, and abstract class as an
  463. >objsys> incomplete implementation construct.
  464. >
  465. >What do you mean by 'complete' and 'incomplete' here?  You may be
  466. >referring to the fact that unfortunately in most (improperly designed)
  467. >OO languages one cannot describe indepdently interfaces and
  468. >implementations, so 'classes' force you to define both together, and
  469. >'abstract classes' are 'incomplete' in the sense that they stand in for
  470. >a proper and separate interface definition facility. If so, I think it
  471. >stinks...
  472.  
  473. No, I like Jade's compositional approach for fine-grained reuse too but
  474. it doesn't handle the usual case of defining a partial implementation.
  475. There's too much literature on this subject to present the case (see
  476. any C++ or Eiffel reference) but quite a few people (actually the majority)
  477. in the object-oriented community will think you stink too if you want to
  478. take away their partial implementation facility;-)  Given that both
  479. facilities can coexist and the standard definition of an abstract class,
  480. do you still argue against abstract classes?
  481.  
  482. >objsys> To what extent are these constructs interchangeable?  Can or
  483. >objsys> should types be used as abstract classes?
  484. >
  485. >Here I might be lost completely. Certainly the specification of a
  486. >mathematical structure is in a different domain from a language idiom
  487. >like an abstract class, and the two are not interchangeable at all.
  488.  
  489. Opps, definitional problems.  We should have cleared this up.  It seemed
  490. as though you were advocating the highest degree of "interoperability"
  491. between abstract types and classes, perhaps it was the definitional problem.
  492. Perhaps you can answer the question again now that you have had a taste of
  493. abstract types and classes.  One basic question is how many syntactic
  494. constructs are required for all the semantic notions of abstract type,
  495. class, and abstract class?  And if more than one, to what degree are they
  496. interchangeable, if at all?  I'm genuinely interested in your response.
  497. It appears to me that abstract types only have a public interface for
  498. what is required whereas classes have a public interface for what they
  499. provide and a private interface for internal use.  Emerald has a type
  500. operation which can be applied to classes giving the maximal type it can
  501. satisfy and I believe with their orthogonal (almost) first-class type system
  502. this type is usable.  Should this type be named and then reused or should
  503. it have been defined in the first place (or should there even be separate
  504. syntactic constructs for the various semantic constructs required)?
  505.  
  506. >objsys> What do you think???
  507. >
  508. >... but surely it would be better if interfaces, specificationa nd
  509. >implementations could be defined _separately_, and there existed
  510. >notation to combine them with each other into a 'class'.  So a 'class'
  511. >would be built out of quite separately defined interfaces,
  512. >implementations and specifications, and only if all three elements were
  513. >present (possibly empty, but this should be documented) it would be
  514. >instantiatable.
  515.  
  516. Actually, this sounds like jibberish to me since I'm not clear
  517. on your definition of interface, specification, and implementation.
  518. Protocol has made it in there too.  Since abstract type and class
  519. have been well defined, perhaps we could agree to communicate in those
  520. terms in this newsgroup?  I believe the terms as I have defined them
  521. are in their canonical form even if the languages and notations which
  522. delineate them are considered under the heading of "alternative
  523. approaches".  I think I approve of and have even covered what you're
  524. advocating, though.
  525.  
  526. >pcg> * given a deque interface, derive stack and queue interfaces by
  527. >pcg>   _subtracting_ the appropriate elements;
  528. >
  529. >objsys> there's only theoretical arguments against it.
  530. >
  531. >Mathematicians do this all the time. We can do it as well. Especially in
  532. >finite domains typical of computing.
  533.  
  534. So the inheritance solution (grab the class (or whatever) and add/delete
  535. part of it) does work.  Another solution is to rearrange the class
  536. (or whatever) lattice to more accurately reflect the new structure.
  537.  
  538. pcg> * given two deque implementations, one with lists and the other
  539. pcg>   with resizable arrays, attach one to a stack interface, and one to
  540. pcg>   a queue interface;
  541.  
  542. [I don't like my last quick answer, so I'll try again.]
  543.  
  544. Jade's compositional approach does this directly.  This shows a finer
  545. degree of reuse can be justified but is not a counter-example to
  546. inheritance; I still contend they are not mutually exclusive and are
  547. both desirable.  The Jade paper (I'll try to give a reference later) lists
  548. many reasons against the use of inheritance but many are outright incorrect
  549. and several are questionable (cases where composition may cause even more
  550. trouble).  If I had more time or if anyone would like to repost them I could
  551. easily defend some form of inheritance against their charges.
  552.  
  553. >pcg> * given a specification of a variable size deque, derive from it a
  554. >pcg>   fixed size deque specification by adding the specification of a size
  555. >pcg>   constraint;
  556. >
  557. >objsys> Just adding a constraint?  Sounds like behavioural inheritance a
  558. >objsys> la DRAGOON.
  559. >
  560. >Yes, again, little bits of what I am saying appear here in there, in
  561. >more or less contrived forms. Modula-3 and to some extent ADA and other
  562. >have got some form of interface specification, and DRAGOON and Eiffel
  563. >and a few others may have got some form of assertion reuse. But we are
  564. >talking of contrivances, not of clear, clean, direct descriptive
  565. >devices. Programming is already hard enough in the substance, to afford
  566. >distraction caused by inappropriate terminology of notation.
  567.  
  568. Well, complain aloud.  If anything is missing I'd love to hear about it.
  569. While deficiencies should clearly be pointed out, proposing feasible
  570. solutions is preferred.  This still doesn't show inheritance has any
  571. problems, though.
  572.  
  573. >objsys> This may be lacking in most OO notations but I don't see it as a
  574. >objsys> fundemental flaw in inheritance.
  575. >
  576. >Well, if by 'inheritance' you mean 'a fully general (including all
  577. >the "obvious" set operations like union, intersection, ...) way to
  578. >independently reuse separately defined interfaces, implementations,
  579. >assertions' then we are entirely agreed. My point precisely.
  580.  
  581. Good.  Actually I believe the correct use of inheritance is to implement
  582. the is-a relation and don't believe that this relation precludes anything
  583. so far discussed or enforces unnecessary hierarchical restrictions (except
  584. as discussed above with classes for the latter).  The set operations sound
  585. interesting though: set union sounds like multiple inheritance.
  586.  
  587. >Unfortunately you have expressed, if I interpreted what you said
  588. >correctly, the notion that 'type systems' should be hierarchical,
  589. >because classification systems should be hierarchical.  
  590.  
  591. No, you misunderstood me.  I simply was trying to point out that
  592. classification has a place in our programming systems, it appeared to
  593. me you felt it didn't.  Inheritance is simply a way to perform
  594. classification and modern variants can handle all possible cases, as
  595. I believe I have shown.
  596.  
  597. >Just for entertainment, I have collected here some of your statements on
  598. >what the word 'type' stands for.
  599.  
  600.   ...
  601.  
  602. I don't see any problems or contradictions in the elided list at all and
  603. after giving an adequate presentation of my terminology, I hope you don't
  604. either!
  605.  
  606. >--
  607. >Piercarlo Grandi                   | JNET: pcg@uk.ac.aber
  608. >Dept of CS, University of Wales    | UUCP: ...!mcsun!ukc!aber-cs!pcg
  609. >Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@aber.ac.uk
  610.  
  611. bob
  612. objsys@netcom.com
  613.