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

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!mips!darwin.sura.net!Sirius.dfn.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!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.92Aug19161314@aberdb.aber.ac.uk>
  6. Date: 19 Aug 92 16:13:14 GMT
  7. References: <PCG.92Aug16184526@aberdb.aber.ac.uk>
  8.     <1992Aug17.222621.1099@neptune.inf.ethz.ch>
  9.     <PCG.92Aug18145434@aberdb.aber.ac.uk>
  10.     <1992Aug18.215440.16673@neptune.inf.ethz.ch>
  11. Sender: news@aber.ac.uk (USENET news service)
  12. Reply-To: pcg@aber.ac.uk (Piercarlo Grandi)
  13. Organization: Prifysgol Cymru, Aberystwyth
  14. Lines: 168
  15. In-Reply-To: santas@inf.ethz.ch's message of 18 Aug 92 21: 54:40 GMT
  16. Nntp-Posting-Host: aberdb
  17.  
  18.  
  19. On 18 Aug 92 21:54:40 GMT, santas@inf.ethz.ch (Philip Santas) said:
  20.  
  21. pcg>       a function over a cartesian product a functional over a function
  22. pcg> over one domain in other words, using a Lisp-like notation, whether
  23. pcg> (plus x y) is really: (apply sum-of (list x y)) (apply (incr-by x) y)
  24.  
  25. santas> In my opinion you do not need to use 'apply in this case.
  26.  
  27. Strictly speaking a Lisp implementation will kindly do this for me
  28. automatically, but I need to do it manually, because I want to make the
  29. point later on that there is a hidden overload resolutor somewhere, so I
  30. try to expose something of what is normally left implicit. Another
  31. example would be rewriting:
  32.  
  33.     [obj message: a and: b]
  34.  
  35. as
  36.  
  37.   _objc_apply(_objc_resolve("message:and:",obj),a,b);
  38.  
  39. which is what Objective C (and Smalltalk) syntax really amounts to, for
  40. example. Once this is clear, one starts to wonder why not have
  41.  
  42.   _objx_apply(_objx_resolve("message:and:",obj,a,b),a,b);
  43.  
  44. and arrives thus to CLOS style multimethods:
  45.  
  46.   (clos_apply (clos_resolve (list 'message-and obj a b)) (list obj a b))
  47.  
  48. In the interest of brevity I have left all such passages implicit, just
  49. hinting at them by showing the first and last one.
  50.  
  51. santas> The correct is: ((incr-by x) y).
  52.  
  53. I made a mistake, but the correct version, for my purposes above, is
  54. '(apply (incr-by x) (list y))', and simply because I did not use apply*
  55. instead of apply, as it is less known. But the intent was well clear, I
  56. hope.
  57.  
  58. santas> Well, all my functions receive one argument, and I think that
  59. santas> most CS scientists and mathematicians agree with this.
  60.  
  61. pcg> Uhmm. But I was speaking of notation/syntax/interface. And the
  62. pcg> notation I was commenting about does have multiple arguments. Your
  63. pcg> observation applies to functions or maybe to procedures, not to
  64. pcg> their interfaces.  Their interfarces are just syntax, notation used
  65. pcg> to access such procedures or their underlying functions. As such
  66. pcg> the notation used is not terribly important, as long as it is
  67. pcg> clear, convenient, and proper.
  68.  
  69. santas> I think that here things are getting mixed up.
  70.  
  71. That's the same feeling I have been getting for a long time...
  72.  
  73. santas> I really find pontless to start a discussion of what is syntax
  74. santas> and what semantics, when the one derives to the second at
  75. santas> different levels of abstraction.
  76.  
  77. Then we should drop this discussion altogether, as we are discussing
  78. syntax and its interactions with pragmatics, and with semantics.
  79.  
  80. But our discussion has title "O.M() versus M(O) notation" it is entirely
  81. proper to analyze the merits of notation, which is
  82. after all what the overload resolution aqgent has to work with.
  83.  
  84. santas> This is why you missed the following three different cases.
  85.  
  86. santas> I propose you to consider (and comment) the following three
  87. santas> cases: M (O,...) [ ... ] (O,...) M [ ... ] O M (...)
  88.  
  89. pcg> This I have already done :-). Prefix, postfix, infix notation
  90.  
  91. santas> It is not so superficial as you try to show. I use all these
  92. santas> cases with the same syntax.
  93.  
  94. Superficially :-)
  95.  
  96. santas> The first case is a function M with argument the tuple (O,...)
  97. santas> (or): M which receives the tuple (O,...), where we have a
  98. santas> function M with a certain type.
  99.  
  100. OK, prefix notation. I really dislike the use of 'receives', but let's
  101. not dwell on that. M is applied to a composite value.
  102.  
  103. santas> In the second case we have (O,...) receiving M. It is not only
  104. santas> superficial change,
  105.  
  106. Yes, it is postfix notation. M is applied to a composite value, which
  107. happens to come before it.  Unless you want, by some strange device,
  108. have the composite value be/evaluate to a functional, and M be its
  109. argument. In that case this is prefix notation.
  110.  
  111. santas> we have the _type_ of the _tuple_ and we have added M to its
  112. santas> specification.
  113.  
  114. So, what's new? Nothing strange really here. For example in C++ one
  115. might well write something like 'complex(0,1).sqrt'. In this example
  116. 'sqrt' is part of the 'complex' class, and is applied to a tuple of that
  117. class. One may declare sqrt as "belonging" to the global environment, to
  118. a class that represents a parameter list, to a specific class. But the
  119. substance does not vary, given an invocation syntax of procedure
  120. interface and list of arguments, resolve it to applying a particular
  121. procedure body to it.
  122.  
  123. santas> In the third case we have O receiving M, producing an instance
  124. santas> (function, object, depending to one's tastes) which operates on
  125. santas> the tuple (...)
  126.  
  127. In other words, by adding parenthesises, in some kind of C++ like
  128. notation, which differs from yours only because of parenthesis,
  129. '(O.M)(...)', something that is actually a fairly common idiom.
  130.  
  131. It is also syntactically similar to the most common interpretation of
  132. multiple arguments, as per my example above. In ML things are more less
  133. like this by default, and you can declare infix operators without
  134. formality. When you write '1 + 2' in ML this is really the same for
  135. '(+ 1) 2'. It's still infix notation.
  136.  
  137.  
  138. I am perplexed as you seem to confuse syntax and semantics (as in the
  139. ordered arguments vs. commutativeness point above), and to be fixated on
  140. the idea that procedures belong to classes, and that the resulting
  141. alternatives in syntax ('a + b' or 'plus(a,b)' or '(a,b).plus' or
  142. 'a.plus(b)' or maybe even '(a.plus)(b)' which all really say the same
  143. thing, even if 'plus' happens to be declared, misleadingly, in a
  144. different place in each case) are fundamental and not incidental. Bah.
  145.  
  146.  
  147. On 18 Aug 92 22:57:39 GMT, santas@inf.ethz.ch (Philip Santas) said:
  148.  
  149. doug> Now, how would this new system help clarify the notions of
  150. doug> abstract types (rectangle and square),
  151.  
  152. pcg> That's a problem for algebrists to solve. What is the optimal
  153. pcg> conceptual orthogonal base for an algebra that encompasses both?
  154. pcg> It's not a problem for the language designer.  The task of the
  155. pcg> latter is to provide clean, general notation to _describe_ such
  156. pcg> things.
  157.  
  158. santas> Why not to _construct_ such things? What is the advantage of
  159. santas> having something _just_ described? (notice that by construction
  160. santas> I do not mean necessarily implementation, but definition of
  161. santas> structures).
  162.  
  163. I have never seen a program that was not a description. I tend to split
  164. hairs and to say that programs describe, and computers read this
  165. description and construct what is described by the program, in the way
  166. described by the program.
  167.  
  168. In a sense it is the age old distinction between programming languages
  169. and algorithmic languages, and between regarding 'print a + b' as a
  170. command or a description of something that should happen.
  171.  
  172. Some programmers things that programs are long lists of commands to make
  173. a computer do things; some think that they are detailed descriptions
  174. that might be read by different entities (mechanical or not), which
  175. might or not result in things being done. The first speak of programs
  176. having bugs; the latter speak of incorrect descriptions.
  177.  
  178.  
  179. I tend to think that programs are descriptions, and the notation used
  180. for such descriptions is not important in itself, as long as it does not
  181. suggest a blinkered vision, like the 'O.M(...)' does.
  182. --
  183. Piercarlo Grandi                   | JNET: pcg@uk.ac.aber
  184. Dept of CS, University of Wales    | UUCP: ...!mcsun!ukc!aber-cs!pcg
  185. Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@aber.ac.uk
  186.