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

  1. From: kers@hplb.hpl.hp.com (Chris Dollin)
  2. Date: Wed, 19 Aug 1992 11:02:13 GMT
  3. Subject: Re: New Language/Compiler (ideas wanted)
  4. Message-ID: <KERS.92Aug19120213@cdollin.hpl.hp.com>
  5. Organization: Hewlett-Packard Laboratories, Bristol, UK.
  6. Path: sparky!uunet!kithrup!stanford.edu!ames!sun-barr!cs.utexas.edu!sdd.hp.com!hpscdc!hplextra!otter.hpl.hp.com!hpltoad!cdollin!kers
  7. Newsgroups: comp.sys.acorn.tech
  8. References: <1195@grun.is> <1992Aug17.132929.10141@waikato.ac.nz> <KERS.92Aug17083517@cdollin.hpl.hp.com> <1992Aug18.114418.10160@waikato.a
  9. Sender: news@hplb.hpl.hp.com (Usenet News Administrator)
  10. Lines: 179
  11. In-Reply-To: bwc@waikato.ac.nz's message of 19 Aug 92 05:36:12 GMT
  12. Nntp-Posting-Host: cdollin.hpl.hp.com
  13.  
  14. In article ... bwc@waikato.ac.nz (Ug!) writes:
  15.  
  16. | Chris Dollin writes:
  17. |>Ug! writes [responding to me]:
  18. |>
  19. |>    Beware: Lisp is essentially an interpreter, even when it's compiled.
  20. |>
  21. |> Would you like to explain the grounds on which you base this claim? [What do
  22. |> you mean by ``essentially'' and ``interpreter''?]
  23. |
  24. | Not really - I think you know what I mean.  I qualify Lisp as an interpreter,
  25. | since much lisp code actually writes lisp programs which are then executed at
  26. | some stage.  I also qualify Smalltalk as an interpreter though, so maybe I'm
  27. | wrong.
  28.  
  29. Well, it seems to me then that you regard a language as ``essentially
  30. interpreted'' if the compiler happens to be available at run-time. OK, it's a
  31. definition; I can live with it, but I don't like it.
  32.  
  33. [Agreement about having a rich library deleted.]
  34.  
  35. |> ``Trivial'' is the word I'd use. Lexical analysers clump up letters into
  36. |> identifiers all the time; what's to stop them clumping up sign characters into
  37. |> operator names? There is *no* problem here, despite what C++ language
  38. |> designers may have tried to tell you. [They're stuck with supporting the
  39. |> lexis of C, and wimped out on requiring whitespace for utterances such as
  40. |> ``x+++y''.]
  41. |
  42. | Read what I said again.  Was I talking about lexical analysis?  No.  I was
  43. | talking about parsing.  Perhaps you feel user defined operators are trivial
  44. | to parse; I don't agree.
  45.  
  46. But there *is* no parsing problem. The lexical analyser recognises operator
  47. symbols (such as ``++'', ``:-'', ``<>'', ``/=='', ``$!##!''), and says to the
  48. parser ``operator symbol, precedence nnn''. The parser is using a grammar
  49. like:
  50.  
  51.     Expr_nn ::= Expr_nn [Op_nn Expr_mm]        (mm < nn, say)
  52.  
  53. and just eats the operator symbol -- in just the same way as it does for
  54. *existing* languages; it just so happens that the spellings allowed for
  55. operator names have become more varied.
  56.  
  57. Now, the only difficulty I can see is that if you feel that user-defined
  58. operators must necessarily have user-defined precedences. *Then* it gets
  59. tricky to parse, because you need the precedences fed back to the lexer *while
  60. the parse is happening*. Yukk. So you *disallow* it; it's not useful enough.
  61. Give all non-standard operators the same precedence (I suggest just tighter
  62. than assignment, if you have assignment).
  63.  
  64. Existance proofs: Algol 68 (but that had user-defined priorities), and HP-SL,
  65. the specification language we did here at the Labs, which had user-defined
  66. operators in almost the style I describe. There were no parsing problems due
  67. to UDOs.
  68.  
  69. [More agreement on the utility of various library types.]
  70.  
  71. |> I'd put the object in the heap and return its address -- a perfectly good
  72. |> handle for the object. I suspect we're at cross-purposes here; what do ADTs
  73. |> gain you in reusability that module scoping does not?
  74. |
  75. | When you have to pass back some sort of handle to the user of a module: not
  76. | internally to a module.  Like C's and Basic's file handles, for example.
  77.  
  78. No, that wasn't what I meant. If you represent an object by its address,
  79. export the object type, but *not* any of the representation-based operations,
  80. (all of which is what you get from what I call a ``module''), then you're just
  81. as abstract as an ADT. Hence the abstractness is nothing to do with the
  82. data-type, it's just to do with name-hiding.
  83.  
  84. |> Ug! responds to my ``GARBAGE COLLECTION'':
  85. |>
  86. |>    Ooo.  Garbage Collection.  Nice.  Still, a big hit in speed/performace,
  87. |>    etc.  See Modula-3 (also has freely available ftp'able descriptions).
  88. |>
  89. |> What big hit did you have in mind?
  90. |
  91. | Garbage collection is fine, but it really does need hardware to support it.
  92. | There has been a lot of work done on stopping the 'sudden hit' (i.e. the
  93. | machine freezes while garbage collection takes place), which early versions
  94. | of Lisp and Smalltalk suffered from.  Most of them however now require a
  95. | steady percentage of the processors time in which to perform garbage
  96. | collection.  Without hardware, this can be quite noticeable, especially as
  97. | memory fills.  (from experience with Smalltalk)
  98.  
  99. My experience with garbage collection is with Poplog (on VAXes and HP
  100. 68K-based workstations), where the ``sudden freeze'' was never long enough to
  101. be a nusiance (until X arrived in the system. Sigh.), and with my own language
  102. Pepper, where the GC time is noticable but the code could be improved no end.
  103. So, unless real-time is an issue, I don't believe the performance hit is
  104. particularly important.
  105.  
  106. |> For simplicitys sake, I'd put it in. I've written too much C, and handled
  107. |> my own store allocation too often, to want to force the poor programmer to
  108. |> do it themselves.
  109. |
  110. | Oh come on!  This is probably the first time this guy has implemented a
  111. | programming language and you want him to put in grabage collection?!!!  Be
  112. | reasonable!  Better to implement a language without garbage collection than
  113. | get bogged down and not manage to implement it at all!
  114.  
  115. Now *that* is a good argument. Just so long as we agree that it's a practical
  116. matter of someone implementing their first language, rather than a desirable
  117. property of languages.
  118.  
  119. |> What does it buy you? Use modules and put up with the fact that B can see X.
  120. |> If necessary have the compiler tell you. The idea is nice, but in practice
  121. |> it's just make-work for the programmer.
  122. |
  123. | Data hiding gains you quite a bit.  Read some stuff on software engineering.
  124. | Essentially its a quality assurance measure.
  125.  
  126. I *know* what data-hiding buys you. I am strongly in favour of data-hiding.
  127. Block structure is one form of such (inner is hidden from outer). But the
  128. requirement of making procedures declare all they import is *too onerous*; it
  129. was tried in Euclid, for example, and they ended up (so I hear) with the
  130. compiler constructing the import lists for the programmer.
  131.  
  132. Modules allow you to do data-hiding (rather, name-hiding). Within a module, it
  133. doesn't seem worth it to require that all names ``falling'' into a procedure
  134. be declared as such. Who are you hiding from? If it's *really* important, use
  135. more modules -- that's what they're there for.
  136.  
  137. [Agreement -- broadly -- on initialised declarations and typed constants,
  138. deleted.]
  139.  
  140. |> incremental compilation;
  141. |
  142. | Maybe.
  143.  
  144. Well, it's harder to do. But it's a good design goal (I think).
  145.  
  146. |> first-class procedures; first-class everything; full lexical scoping.
  147. |
  148. | Can you explain these a little more?  I'm not that familiar with Common Lisp
  149. | or Scheme, I'm afraid.
  150.  
  151. Tale this little example written in Pepper (the current compiler can't handle
  152. it, but that's just laziness on my part; I can tell you how it *will* be
  153. implemented if you want):
  154.  
  155.     define adder( n ) as
  156.         define add_n( m ) as n + m enddefine;
  157.         add_n
  158.     enddefine;
  159.  
  160.     val add1 = adder( 1 );
  161.     val add2 = adder( 2 );
  162.  
  163.     add1( 41 ) =>
  164.  
  165.     ** 42
  166.  
  167. ``adder'' is a procedure which, when called with some value ``n'', returns a
  168. procedure which, when applied to some argument ``m'', delivers the sum of
  169. ``n'' and ``m''. ``add1'' and ``add2'' are procedures delivered by ``adder''
  170. for different n's -- they have a variable ``n'' *each*.
  171.  
  172. Lexical scoping means that ``n'' is in scope in the region of text in which it
  173. is declared, including in any nested procedures (here, ``add_n''). (Even
  174. Pascal can do this, although C cannot.) *Full* lexical scoping means that the
  175. variable ``n'' will persist for as long as necessary -- in this case, it
  176. cannot be allocated on the stack, as it needs to survive ``adder'' so that it
  177. remains available to (some instance of) ``add_n''.
  178.  
  179. ``First-class everything'' means that all objects (values) have (in some
  180. sense) equal rights; being passed as parameters, returned as results, stored
  181. in data-structures, or assigned. This applies particularly to procedures,
  182. which are often short-changed (C only admits them with the locution
  183. ``pointer-to-function'', and doesn't permit them to be declared nested; see
  184. ``full lexical scoping'').
  185.  
  186. As a language design rule, it says you should make the distinction between
  187. an object (value) and its name clear. Unfortunately, first-class-ness usually
  188. needs garbage collection to make it possible ...
  189. --
  190.  
  191. Regards,    | ``In fingers of trees, and valleys of gold    | Judy Tzuke
  192. Kers.       | I watch as you outshine the charlatan foe.''  | Higher & Higher
  193.