home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / object / 3206 < prev    next >
Encoding:
Internet Message Format  |  1992-08-14  |  16.7 KB

  1. Path: sparky!uunet!mcsun!uknet!gdt!aber!aberfa!pcg
  2. From: pcg@aber.ac.uk (Piercarlo Grandi)
  3. Newsgroups: comp.object
  4. Subject: Re: O.M() versus M(O) notation
  5. Message-ID: <PCG.92Aug14170701@aberdb.aber.ac.uk>
  6. Date: 14 Aug 92 17:07:01 GMT
  7. References: <1992Aug5.162329.22871@ucunix.san.uc.edu> <PCG.92Aug12205741@aberdb.aber.ac.uk>
  8.     <__5mtrq.objsys@netcom.com>
  9. Sender: news@aber.ac.uk (USENET news service)
  10. Reply-To: pcg@aber.ac.uk (Piercarlo Grandi)
  11. Organization: Prifysgol Cymru, Aberystwyth
  12. Lines: 372
  13. In-Reply-To: objsys@netcom.com's message of 13 Aug 92 01: 58:32 GMT
  14. Nntp-Posting-Host: aberdb
  15.  
  16. On 13 Aug 92 01:58:32 GMT, objsys@netcom.com (Bob Hathaway) said:
  17.  
  18. pcg> There is, I am afraid, the usual fuzziness as to what the word
  19. pcg> "type" is intended to mean: a denotation, an implementation, a
  20. pcg> declaration?
  21.  
  22. objsys> Type is well defined.
  23.  
  24. Really? I see the word 'type' used with very different referents by
  25. different people at different times. At some of these times I get a
  26. strong suspicion that they themselves are not clear as to what they are
  27. talking about.
  28.  
  29. objsys> In ASU's Compilers, type is defined as "the type of a construct
  30. objsys> matches that expected by its context" and includes checking that
  31. objsys> an operator (and perhaps method) is applied to a compatible
  32. objsys> operand(receiver).
  33.  
  34. This is the kind of definition expected in a compiler writer's book. It
  35. is highly related to the notational (it refers to "construct"s,
  36. "operator"s and "operand"s, which are syntactic entities) aspects of a
  37. program. Here you seem to define 'type' as 'type as declared/defined in
  38. a program text'.
  39.  
  40. objsys> No mention is made of implementation since type systems only
  41. objsys> deal with types.
  42.  
  43. Hardly surprising! If 'type systems' were dealing with blondes, than
  44. that would be news!
  45.  
  46. objsys> Kim and Lochovsky in OO Concepts, Databases and Applications
  47.  
  48. A particularly badly written and hopelessly fuzzy book. I urge everybody
  49. to read it, just for the experience! (Loan it from your library! Don't
  50. buy it! Don't reward such works!). After reading this book you will
  51. start to think that my postings are as well written and thought out as
  52. Gettysburg's address, by comparison.
  53.  
  54. objsys> clearly
  55.         ^^^^^^^
  56. An adjective that seems out of context here, somehow.
  57.  
  58. objsys> distinguish between the superficial difference between type and
  59. objsys> class and define type purely as specifications.
  60.  
  61. Of what? Of the underlying algebra? Of the syntax used for the type
  62. description?
  63.  
  64. objsys> So "In the presence of dynamic binding it is (in general)
  65. objsys> impossible to determine statically the class of a variable, but
  66. objsys> with the appropriate type rules we can still perform
  67. objsys> type-checking."
  68.  
  69. Another lot of meaningless, self referential verbiage. One could rewrite
  70. it as
  71.  
  72.     "In the presence of type checking with deterministic type rules
  73.     it is in general appropriate to perform..."
  74.  
  75. or any other permutation of this fine collection of buzz words, and the
  76. meaning would not change.
  77.  
  78. objsys> They go on to give examples but this sort of definition (as also
  79. objsys> quoted from Booch in my last posting) is *so* common I think it
  80. objsys> already has been adopted as a standard.
  81.  
  82. Ah, such fumbling with buzzwords is all too common, it is virtually a
  83. standard. Insight is not a standard instead; last year there were these
  84. two guys, a well known Professor, and a well known Consultant, that had
  85. never realized that objects (except in actor based languages) are indeed
  86. (implemented as) closures, something that is not just 'obvious', but
  87. also is clearly and incontrovertibly described in a first year
  88. programming textbook from MIT... Bah.
  89.  
  90. objsys> Class (or whatever) defines implementation and type defines an
  91. objsys> abstract specification.
  92.  
  93. Ah, here we get (from you! not from any of the famous authors above) a
  94. more clear distinction: here you seem to be saying that the referent
  95. for the word 'type' is the formal description of a mathematical entity,
  96. of an algebraic structure, and that 'class' is the (corresponding?)
  97. implementation. This is quite different from the definition given in the
  98. AWU book on compilers, that you seem to agree with above.
  99.  
  100. This is open to many observation:
  101.  
  102. * why have 'type' have as referent the formal specification of a
  103.   mathematical entity and not the mathematical entity itself? You
  104.   seem to be saying that 'type' Unsigned is not the algebra of modulo
  105.   2^N naturals, but a formal specification of that algebra. There can be
  106.   many different formal specifications for that algebra. Which one is
  107.   meant by 'type' Unsigned?
  108.  
  109. * Why use 'type' do refer to the underlying mathematical entity, or its
  110.   formal specification? In virtually all existing languages the keyword
  111.   'type' refers to the syntax defining an algorithmic description of the
  112.   underlying mathematical entity. This is bound to be confusing, as in
  113.   "are you talking about 'type complex = record re,im: real end;' or
  114.   about the 'type' Complex (which is quite a different thing
  115.   semantically!".
  116.  
  117. * If 'class' refers to the implementation of a 'type', does it refer to
  118.   the interface or to the code behind that interface or to the
  119.   assertions that decorate ? They are all 'implementation'! And if it
  120.   refers to all of them at the same time, how can I distinguish between
  121.   those orthogonal aspects? 
  122.  
  123. objsys> Perhaps this is a clue to the solution of the age old proverb:
  124. objsys>        Why not concrete data types?
  125. objsys> Types can be viewed as abstract data types, and classes (or
  126. objsys> whatever representational construct) can be viewed as concrete
  127. objsys> ones!
  128.  
  129. More meaningless/fuzzy verbiage...
  130.  
  131. pcg> In cases where they they are needed, writing a specification and
  132. pcg> getting it right is a hard job.
  133.  
  134. objsys> How so?  I don't see that its any harder than writing the class
  135. objsys> specification.
  136.  
  137. Ah surely; an argument could be made that actually they are the one and
  138. same thing, otherwise the 'class' is not a faithful algorithmic
  139. representation of the corresponding 'type'
  140.  
  141. objsys> Just define what's required.
  142.  
  143. pcg> It's that "just" that drives one crazy. Writing proper specifications
  144. pcg> is often *harder* than writing the corresponding code, and longer.
  145.  
  146. objsys> Perhaps we're confusing terminology;
  147.  
  148. Ah, that's one of the few sure things in this discussion.
  149.  
  150. objsys> it appears to me that writing class specifications and type
  151. objsys> specifications are not much different.
  152.  
  153. Ah indeed, and both are fiendishly difficult things. Just try to write a
  154. *full* formal specification for a B-Tree 'type'.
  155.  
  156. objsys> Perhaps you're discussing the greater difficulty posed by
  157. objsys> creating both kinds of specifications verses that of creating
  158. objsys> the class/rep implementation?
  159.  
  160. Probably yes, indeed.
  161.  
  162. pcg> The trouble that many people have is that they don't define their
  163. pcg> terms precisely. The confusion between type as denotation and
  164. pcg> representation and syntax is rampant. Probably you are right to
  165. pcg> suspect that Booch is not very clear about it himself, not just
  166. pcg> "mortals".
  167.  
  168. objsys> I think Booch's definition is correct but IMHO he blew it by
  169. objsys> combining the two in his presentation, hence the real confusion.
  170. objsys> Hopefully we may have cleared up this confusion, at least in
  171. objsys> this newsgroup.
  172.  
  173. Well, that's quite optimistic.
  174.  
  175. objsys> Type (specification) defines an abstract interface
  176.  
  177. Ah no, here you are changing your mind again! Or maybe I misread you
  178. above: you seemed to say that 'type' is the formal specification
  179. describing a mathematical entity, now you ssaying it is the
  180. specification of an abstract *interface*? I am confused: does 'type'
  181. refer to interfaces (something that belong in programs) or semantics
  182. (something that belong in mathematics)?
  183.  
  184. objsys> and Class (or whatever representational/implementation
  185. objsys> device as appropriate) defines the concrete structure of an
  186. objsys> object.
  187.  
  188. So 'class' is only the structure of an object, not the implementation of
  189. operations on it?
  190.  
  191. pcg> Again, while I agree with the meaning, some linguistic difference:
  192. pcg> I find slightly disturbing to talk of object type and class. Maybe
  193. pcg> one should say 'type denotation' or semantics instead of 'object
  194. pcg> type', and 'type declaration' instead of 'class' (class syntax is
  195. pcg> just one of the possible syntaxes used to declare a type).
  196.  
  197. objsys> No, type and type systems are independent of implementation.  I
  198. objsys> think this distinction is very important from both a compiler
  199. objsys> and applications point of view.
  200.  
  201. But the compiler never sees any of 'type' and 'type system'! The
  202. compiler only sees interfaces and implementations! Or, at best,
  203. assertions that decorate them and are derived from specifications.
  204.  
  205. pcg> There is absolutely no reason to believe that structural reuse
  206. pcg> opportunities need to happen in a hierarchical fashion like with
  207. pcg> inheritance.
  208.  
  209. objsys> Sure there is.  We do it all the time; its called
  210. objsys> classification.
  211.  
  212. Yes, but all hierarchical taxonomies are inappropriate, in the sense
  213. that they always cause bad classifications. Just consider the Unix
  214. filesystem; one is forced to choose between thse two organizations:
  215.  
  216.     c_compiler/bin c_compiler/bin ada_compiler/man ada_compiler_man
  217.     bin/c_compiler bin/ada_compiler man/c_compiler man/ada_compiler
  218.  
  219. when neither is really appropriate; the man page for the ada compiler is
  220. both a man page and part of the ada compiler package, and neither aspect
  221. prevails. Similarly in many data design instances. Hierarchical database
  222. models have fallen from favour because they forced people to do data
  223. designs that were strict taxonomies, that are inappropriate almost
  224. always, except for 'parts explosion' situations.
  225.  
  226. objsys> Once wants the ability (my favourite peeve) to independently
  227. objsys> reuse interfaces, specifications, and implementations, and a
  228. objsys> general purpose algebra for all of thse things.
  229.  
  230. objsys> Some systems with inheritance may not provide this but I don't
  231. objsys> see any inherent restrictions.
  232.  
  233. Well, except that you insist otherwise that type systems should be
  234. hierarchical. Isn't that a fairly large inherent restriction?
  235.  
  236. objsys> Another good question: lets define type as an abstract
  237. objsys> specification,
  238.  
  239. Here we are back to 'type' as 'abstract specification', not 'interface
  240. specification'. Still, I am puzzled by your insistence that 'type'
  241. should refer to the specification itself, and not the mathematical
  242. entity described by the specification.
  243.  
  244. objsys> class as an implementation construct, and abstract class as an
  245. objsys> incomplete implementation construct.
  246.  
  247. What do you mean by 'complete' and 'incomplete' here?  You may be
  248. referring to the fact that unfortunately in most (improperly designed)
  249. OO languages one cannot describe indepdently interfaces and
  250. implementations, so 'classes' force you to define both together, and
  251. 'abstract classes' are 'incomplete' in the sense that they stand in for
  252. a proper and separate interface definition facility. If so, I think it
  253. stinks...
  254.  
  255. objsys> To what extent are these constructs interchangeable?  Can or
  256. objsys> should types be used as abstract classes?
  257.  
  258. Here I might be lost completely. Certainly the specification of a
  259. mathematical structure is in a different domain from a language idiom
  260. like an abstract class, and the two are not interchangeable at all. Have
  261. you gone back to the definition of 'type' as 'interface specification'?
  262. If so, I can only emphatically agree that 'no' is the answer to your
  263. rhetorical question:
  264.  
  265. objsys> If so, should abstract classes exist at all?
  266.  
  267. objsys> Should classes without their implementations be usable as types
  268. objsys> (grab their public interface only) to allow for multiple
  269. objsys> implementations?
  270.  
  271. I agree with some of sentiment here...
  272.  
  273. objsys> What do you think???
  274.  
  275. ... but surely it would be better if interfaces, specificationa nd
  276. implementations could be defined _separately_, and there existed
  277. notation to combine them with each other into a 'class'.  So a 'class'
  278. would be built out of quite separately defined interfaces,
  279. implementations and specifications, and only if all three elements were
  280. present (possibly empty, but this should be documented) it would be
  281. instantiatable.
  282.  
  283. pcg> * given a deque interface, derive stack and queue interfaces by
  284. pcg>   _subtracting_ the appropriate elements;
  285.  
  286. objsys> there's only theoretical arguments against it.
  287.  
  288. Mathematicians do this all the time. We can do it as well. Especially in
  289. finite domains typical of computing.
  290.  
  291. objsys> You could also include the deque as a member of stack and queue
  292. objsys> and simply don't redefine the subtracted interface.  This should
  293. objsys> be the preferred solution.
  294.  
  295. Why ever preferred? Probably it would be a very inappropriate, and
  296. redundant, description of a stack. A stack is not *implemented* using a
  297. deque, it is an entity on the same abstraction level as a deque, only
  298. not as general. Both a deque and a stack may *share* (reuse) certain
  299. elements of their interfaces, implementations, assertions, simply
  300. because the underlying algebras are largely overlapping. This should be
  301. directly reflected in the program text.
  302.  
  303. pcg> * given two deque implementations, one with lists and the other
  304. pcg>   with resizable arrays, attach one to a stack interface, and one to
  305. pcg>   a queue interface;
  306.  
  307. objsys> Given an abstract dequeue class with two implementation classes,
  308. objsys> List_Dequeue and Array_Deque, why not derive Stack from
  309. objsys> List_Dequeue and Queue from Array_Dequeue.
  310.  
  311. But I want to derive the stack and queue *interfaces* from the *deque*
  312. interface (or viceversa of course!), and then _independently_ attach
  313. (parts of) any of the deque *implementation*s to either. Speaking of
  314. 'derivation' is absolutely misleading and appropriate; 'derivation' is
  315. just a particular (and hierarchical) way to do reause. Here I want to be
  316. able to directly reuse separately defined components and mix and match
  317. them to build 'classes'.
  318.  
  319. I think the alternatives you are giving are just hacks; yes, some things
  320. can be done even with popular inheritance based languages, but forcing
  321. things. Compare 'abstract classes' with pure 'interface specifications'.
  322. In the former case you are tempted to use the word 'incomplete class',
  323. in the latter you know that an interface specification is part of class
  324. definition, but is a fundamentally different entity.
  325.  
  326. pcg> * given a specification of a variable size deque, derive from it a
  327. pcg>   fixed size deque specification by adding the specification of a size
  328. pcg>   constraint;
  329.  
  330. objsys> Just adding a constraint?  Sounds like behavioural inheritance a
  331. objsys> la DRAGOON.
  332.  
  333. Yes, again, little bits of what I am saying appear here in there, in
  334. more or less contrived forms. Modula-3 and to some extent ADA and other
  335. have got some form of interface specification, and DRAGOON and Eiffel
  336. and a few others may have got some form of assertion reuse. But we are
  337. talking of contrivances, not of clear, clean, direct descriptive
  338. devices. Programming is already hard enough in the substance, to afford
  339. distraction caused by inappropriate terminology of notation.
  340.  
  341. objsys> This may be lacking in most OO notations but I don't see it as a
  342. objsys> fundemental flaw in inheritance.
  343.  
  344. Well, if by 'inheritance' you mean 'a fully general (including all
  345. the "obvious" set operations like union, intersection, ...) way to
  346. independently reuse separately defined interfaces, implementations,
  347. assertions' then we are entirely agreed. My point precisely.
  348.  
  349. Unfortunately you have expressed, if I interpreted what you said
  350. correctly, the notion that 'type systems' should be hierarchical,
  351. because classification systems should be hierarchical.  This is quite a
  352. more restrictive statament. Most of the verbi^H^H^H^H^Hliterature on
  353. this subject tends to agree with you (there are even several articles on
  354. formalization of inheritance, which only have little more merit than
  355. those on formalization of exception handling).
  356.  
  357. All in all, I think that just problems with buzzw^H^H^H^H^Hterminology
  358. loom so large in any such discussion that it is hard to make any
  359. progress. Still trying, though.
  360.  
  361. Just for entertainment, I have collected here some of your statements on
  362. what the word 'type' stands for.
  363.  
  364. objsys> Class (or whatever) defines implementation and type defines an
  365. objsys> abstract specification.
  366.  
  367. objsys> Type (specification) defines an abstract interface [ ... ]
  368.  
  369. objsys> Can or should types be used as abstract classes?
  370.  
  371. objsys> [ ... ] lets define type as an abstract specification, class as
  372. objsys> an implementation construct, and abstract class as an incomplete
  373. objsys> implementation construct.
  374.  
  375. objsys> In ASU's Compilers, type is defined as "the type of a construct
  376. objsys> matches that expected by its context" and includes checking that
  377. objsys> an operator (and perhaps method) is applied to a compatible
  378. objsys> operand(receiver).
  379.  
  380. objsys> [ ... ] type and type systems are independent of implementation.
  381.  
  382.  
  383.  
  384. --
  385. Piercarlo Grandi                   | JNET: pcg@uk.ac.aber
  386. Dept of CS, University of Wales    | UUCP: ...!mcsun!ukc!aber-cs!pcg
  387. Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@aber.ac.uk
  388.