home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / function / 1022 < prev    next >
Encoding:
Text File  |  1992-08-20  |  6.3 KB  |  168 lines

  1. Newsgroups: comp.lang.functional
  2. Path: sparky!uunet!decwrl!deccrl!news.crl.dec.com!nikhil
  3. From: nikhil@crl.dec.com (R.S. Nikhil)
  4. Subject: Re: Definitions
  5. Message-ID: <1992Aug20.162659.10144@crl.dec.com>
  6. Sender: news@crl.dec.com (USENET News System)
  7. Organization: DEC Cambridge Research Lab
  8. References:  <9910@uqcspe.cs.uq.oz.au>
  9. Date: Thu, 20 Aug 1992 16:26:59 GMT
  10. Lines: 156
  11.  
  12. In article <9910@uqcspe.cs.uq.oz.au>, michaeln@cs.uq.oz.au (Michael Norris) writes:
  13. > A quick question.
  14. > Where can I find good definitions of the words relating to
  15. > functional programming? ...
  16. > Specifically,
  17. >     ...
  18. >     list comprehension
  19. >     ...
  20.  
  21.  
  22. You may be interested in the note, attached below, which I wrote recently.
  23.  
  24. Regards,
  25.  
  26. Nikhil
  27. ------------------------------------------------------------
  28. NAME:      Rishiyur S. Nikhil
  29. EMAIL:     nikhil@crl.dec.com
  30. TELEPHONE: (617) 621 6639        FAX : (617) 621 6650
  31. ADDRESS:   Digital Equipment Corporation,
  32.            Cambridge Research Laboratory,
  33.            One Kendall Square, Bldg. 700, Cambridge, MA 02139, USA
  34. ================================================================
  35.  
  36.     NOTES ON THE ORIGIN OF THE TERM ``LIST COMPREHENSION''
  37.                Rishiyur Nikhil
  38.                 September 1991
  39.          (revised January 1992, August 1992)
  40.  
  41. Recently, I did a little research into the origins of the term ``list
  42. comprehension'' (since I wanted to attribute it correctly in a book
  43. that I am writing).  I corresponded with several people, including
  44. Phil Wadler, Rod Burstall and John Darlington.  This is what I learned
  45. (of course, I'd be happy to receive comments/corrections to this
  46. account).
  47.  
  48. The term itself seems to have been coined by Phil Wadler circa
  49. 1983-1985, although the programming construct itself goes back much
  50. further (most likely Jack Schwartz and the SETL language).
  51.  
  52. The earliest reference to the notation that I have is in the following
  53. paper:
  54.  
  55.     ``Program Transformation and Synthesis: Present Capabilities''
  56.     John Darlington
  57.     Research Report No. 77/43, Dept. of Computing and Control, Imperial
  58.     College of Science and Technology, London (also appears as
  59.     Report No. 48, Dept. of Artificial Intelligence, U. of Edinburgh)
  60.     September 1977
  61.  
  62. which describes a functional language called NPL, designed by Rod
  63. Burstall and John Darlington.  The report contains the following
  64. passage:
  65.  
  66.     ``In addition, NPL allows certain sets and logic constructs to appear
  67.     on the right hand side, for example
  68.  
  69.         setofeven(X) <= <:x: x in X & even(x) :>
  70.  
  71.     ...
  72.  
  73.     ... NPL allows certain sets and logic constructs on the right hand side
  74.     of equations.  The concrete syntax of these constructs is:
  75.  
  76.         setexpression ::= <:expression: generator* :>
  77.         ...
  78.         generator     ::= variable IN expression (range) * expression (condition)
  79.  
  80.     The NPL interpreter evaluates the list of generators in a left to right
  81.     fashion so conditions can mention any bound variables that occur to
  82.     their left.''
  83.  
  84. and, amusingly:
  85.  
  86.     ``The interpreter is able to run many programs written
  87.     using these facilities, but some program written are horrendously
  88.     inefficient while others are not runnable as they stand.''
  89.  
  90. In that report, Darlington also goes on to show how to implement these
  91. expressions by transformation (similar to the translation shown by
  92. Wadler in Peyton Jones' book [Ch. 7, The Implementation of Functional
  93. Languages, Simon L. Peyton Jones, Prentice Hall 1987]).
  94.  
  95. The following contemporary paper also discusses the set expression
  96. notation in NPL:
  97.  
  98.     "Design Considerations for a Functional Programming Language",
  99.     Burstall, Rod M.,
  100.     in "Infotech State of the Art Conference: The Software Revolution,
  101.         Copenhagen"
  102.     October 1977
  103.  
  104. The paper contains the following passage, where Burstall attributes
  105. the notation originally to Schwarz and SETL (he also mentioned this to
  106. me in a personal communication).  The concrete syntax seems to have
  107. changed slightly:
  108.  
  109.   ``To make it easier to work with sets, we permit a notation very similar
  110.     to mathematical usage (following Schwarz in his SETL language).
  111.     Suppose for example that we already have constants s and t denoting
  112.     sets of numbers, then a typical set expression would be
  113.  
  114.         {i + j : i in s, j in union (s,t) & i < j}
  115.  
  116.     The general form is:
  117.  
  118.         {EXPRESSION : VARIABLE in EXPRESSION & EXPRESSION, ...,
  119.                       VARIABLE in EXPRESSION & EXPRESSION}
  120.  
  121.     We also allow explict sets like {1,2,3}.  So
  122.  
  123.         {i+j : i in {1,2,3}, j in {1,2,3} & i = j}   is  {2,4,6}''
  124.  
  125. John Darlington says that he and Rod Burstall introduced the notation
  126. into NPL to make up for the lack of higher-order capability in NPL.
  127. This was shortly after Darlington came to Edinburgh for his Ph.D.
  128. straight after a degree at the London School of Economics which
  129. included a fair bit of logic and in particular ZF (Zermelo-Frankel)
  130. set theory.
  131.  
  132. Darlington also says that at the same time Richard Waldinger at SRI
  133. was using the same constructs as specification lannguage for his
  134. program synthesis work.
  135.  
  136. David Turner subsequently adopted this notation in his languages SASL,
  137. KRC and Miranda*, where he has called them ``zf expressions'' (in his
  138. 1981 FPCA paper [The Semantic Elegance of Applicative Languages])
  139. set-abstractions and list-abstractions (in his 1985 FPCA paper
  140. [Miranda: A Non-Strict Functional Language with Polymorphic Types]).
  141.  
  142. Phil Wadler says he believes he originated the term ``list
  143. comprehension'' after a conversation with John Hughes, where he
  144. bemoaned the current nomenclature and Hughes reminded him of the
  145. existing term ``set comprehension''.  The term ``list comprehension''
  146. appears in the following:
  147.  
  148.     ``The OL Manual''
  149.     Philip Wadler, Quentin Miller and Martin Raskovsky
  150.     Probably 1983-1985 (my copy is undated)
  151.  
  152. The term ``list comprehension'' also appears in quotation marks in
  153. Wadler's 1985 FPCA paper:
  154.  
  155.     ``How to Replace Failure by a List of Successes''
  156.     FPCA September 1985, Nancy, France, pp 113-146
  157.  
  158. Interestingly, I have a pre-publication version of this paper dated
  159. January 1985 where the term used in exactly the same place (last
  160. sentence of para 2) is ``list abstraction'', i.e., it seems to have
  161. been substituted by ``list comprehension'' in the intervening months
  162. before publication.
  163.  
  164. ----------------------------------------------------------------
  165. * ``Miranda'' is a trademark of Research Software, Ltd.
  166.