home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / object / 3245 < prev    next >
Encoding:
Internet Message Format  |  1992-08-18  |  6.8 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.92Aug18145434@aberdb.aber.ac.uk>
  6. Date: 18 Aug 92 14:54:34 GMT
  7. References: <PCG.92Aug14170701@aberdb.aber.ac.uk> <1992Aug15.124149.28538@m.cs.uiuc.edu>
  8.     <PCG.92Aug16184526@aberdb.aber.ac.uk>
  9.     <1992Aug17.222621.1099@neptune.inf.ethz.ch>
  10. Sender: news@aber.ac.uk (USENET news service)
  11. Reply-To: pcg@aber.ac.uk (Piercarlo Grandi)
  12. Organization: Prifysgol Cymru, Aberystwyth
  13. Lines: 147
  14. In-Reply-To: santas@inf.ethz.ch's message of 17 Aug 92 22: 26:21 GMT
  15. Nntp-Posting-Host: aberdb
  16.  
  17. On 17 Aug 92 22:26:21 GMT, santas@inf.ethz.ch (Philip Santas) said:
  18. santas> (Piercarlo Grandi) writes:
  19.  
  20. pcg> [ ... ] it makes a lot of difference which notation
  21. pcg> is used to describe operations on a value because the notation
  22. pcg> strongly influences thought processes and actually constrains them
  23. pcg> (cfr. Dijkstra on BASIC), and that in particular the 'O.M(...)'
  24. pcg> notation by making 'O' visually special suggests that overloading
  25. pcg> should happen only on the first argument
  26.  
  27. santas> Although I agree partly with this I have a major dissagreement:
  28. santas> you seem to argue that functions receive more than one
  29. santas> arguments.
  30.  
  31. Ah no, ah no. I have not committed myself on this! (even if a lot of
  32. people would like to commit me! :->). Here I would make the point that
  33. there is some difference between 'function' and 'procedure'. In the case
  34. of 'function' there is some disagreement, dutifully reflected in the
  35. syntax of ML 'procedures' for example, as to whether a function over two
  36. domains is really:
  37.  
  38.     a function over a cartesian product 
  39.     a functional over a function over one domain
  40.  
  41. in other words, using a Lisp-like notation, whether (plus x y) is really:
  42.  
  43.     (apply sum-of (list x y))
  44.     (apply (incr-by x) y)
  45.  
  46. I tend to prefer the latter, also because I like Indian sauces :->, as
  47. it becomes much easier to do things like partial application.
  48.  
  49. But here we are speaking of 'functions', or maybe of procedures, not of
  50. procedure interfaces.
  51.  
  52. santas> Well, all my functions receive one argument, and I think that
  53. santas> most CS scientists and mathematicians agree with this.
  54.  
  55. Uhmm. But I was speaking of notation/syntax/interface. And the notation
  56. I was commenting about does have multiple arguments. Your observation
  57. applies to functions or maybe to procedures, not to their interfaces.
  58. Their interfarces are just syntax, notation used to access such
  59. procedures or their underlying functions. As such the notation used is
  60. not terribly important, as long as it is clear, convenient, and proper.
  61.  
  62. santas> Since I do not like the O.M(...) syntax and your functions with
  63. santas> _many_ arguments,
  64.  
  65. So, I am not really talking about functions/procedures with many
  66. arguments; I am just talking as their interfaces. Then the compiler, on
  67. recognizing an interfaces like
  68.  
  69.     1 + 2
  70.  
  71. will either build a record '{1,2}' and pass it to 'operator+', as is
  72. done in most traditional languages (where the activation frame of a
  73. procedure is really a record), or will generate a functional and apply
  74. it, as is customarily done in ML.
  75.  
  76. santas> I propose you to consider (and comment) the following three
  77. santas> cases: M (O,...) [ ... ] (O,...) M [ ... ] O M (...)
  78.  
  79. This I have already done :-). Prefix, postfix, infix notation:
  80.  
  81. pcg> As far as syntaxes go, everybody have their own personal tastes;
  82. pcg> some prefer infix, some prefix, some postfix, some expression based
  83. pcg> languages, some imperative one.
  84.  
  85. And let me add: some prefer keyword based, so infix/prefix/postfix does
  86. not matter.
  87.  
  88. Frankly what I really care about is not the notation itself, but the
  89. fact that the overload resolution agent (aka binder, dispatcher,
  90. messager, etc.) is given an N-uple
  91.  
  92.     (O,M,A,B,C,...)
  93.  
  94. which may or may not be ordered (even if usually the A,B,C,... are
  95. positional and thus ordered), and from this it has to find a compatible
  96. implementation/body/etc. to apply. I quite like the prefix lisp notation
  97.  
  98.     (M O A B C ...)
  99.  
  100. that more clearly reflects this, and is in some way just a shorthand for
  101.  
  102.     (apply (resolve M O A B C ...) A B C ...)
  103.  
  104. And indeed that is the way the Lisp systems reads it.
  105.  
  106. santas> Can you describe or outline a general purpose method for
  107. santas> automatic subsetting?
  108.  
  109. That is a fairly ambitious goal, I am afraid, in its full generality.
  110. Church has to say something about it. But, if I am right in thinking
  111. that what you really mean is 'a way where, given a more general set of
  112. interface or specification or implementation components, a more
  113. specialized set can be derived' then a less than general and highly
  114. useful _practical_ solution is possible.
  115.  
  116. By coupling an interpreter to a compiler, and maybe also adding in an
  117. inference engine, to result in a symbolic reduction compiler. There is
  118. some research being done in this, and I wish it were a more popular
  119. endeavour. A large number of useful cases can be handled even with
  120. fairly simplistic technology.
  121.  
  122. santas> Concerning specification: I think that subclasses should inherit
  123. santas> it as a whole, otherwise there is no point for making a class
  124. santas> subclass of another.
  125.  
  126. Maybe, but probably you are still thinking in terms of inheritance, as
  127. your use of the seven letter verb indicates. There is no reason to
  128. believe that if one has a general algebra over interfaces specifications
  129. and implementations, derivation need only happen by subsetting. For
  130. example one could derive a more general class from a less general one,
  131. usually by adding (or substituting) interface and implementation
  132. components, and the specification of the resulting class might well be
  133. weaker.
  134.  
  135. For example, once one has written interface and specification and
  136. implementation components for fixed length queues, one might want to
  137. reuse (be it ever praised!) them, or parts of them, to build a
  138. dynamically resizable queue class. In this case the derived
  139. specification will not have the assertion that 'items <= maxitems'.
  140.  
  141. santas> The problem with interface is that current OOPLs do not use
  142. santas> functors for classes, ie. functions which construct new classes
  143. santas> out of older ones.
  144.  
  145. On this we are thoroughly agreed, actually it is my main point. It is
  146. this that I have in mind when I say that languages should have notation
  147. to cover full general algebras over interfaces, implementations,
  148. specifications; those 'functors' of yours are the operators of such
  149. algebras.
  150.  
  151. Even if most current languages do have some 'functors' over 'types',
  152. i.e.  type constructors, e.g. 'array', 'struct', 'pointer to', 'union',
  153. etc., as most current OO languages do have some 'functors' over
  154. 'classes', e.g. the ':' of C++, or 'inherits' of Eiffel.
  155.  
  156. But yes, they lack the necessary flexibility and generality.
  157.  
  158.  
  159.  
  160. --
  161. Piercarlo Grandi                   | JNET: pcg@uk.ac.aber
  162. Dept of CS, University of Wales    | UUCP: ...!mcsun!ukc!aber-cs!pcg
  163. Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@aber.ac.uk
  164.