home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / compiler / 2054 < prev    next >
Encoding:
Text File  |  1992-12-20  |  2.8 KB  |  65 lines

  1. Newsgroups: comp.compilers
  2. Path: sparky!uunet!usc!sol.ctr.columbia.edu!eff!world!iecc!compilers-sender
  3. From: Peter Ludemann <ludemann@quintus.com>
  4. Subject: Re: Extension Languages 
  5. Reply-To: Peter Ludemann <ludemann@quintus.com>
  6. Organization: Compilers Central
  7. Date: Thu, 17 Dec 1992 22:34:22 GMT
  8. Approved: compilers@iecc.cambridge.ma.us
  9. Message-ID: <92-12-086@comp.compilers>
  10. Keywords: design, interpreter
  11. References: <92-12-064@comp.compilers>
  12. Sender: compilers-sender@iecc.cambridge.ma.us
  13. Lines: 50
  14.  
  15. Dave Gillespie <daveg@thymus.synaptics.com> writes:
  16. >    notation:    infix        prefix        postfix
  17. >    example:    C, Pascal    Lisp        Forth, PostScript
  18. >    syntax:    parens, opers, ...    parentheses    "none"
  19. >    humans:        easy        okay        hard
  20. >    machines:    hard        okay        easy
  21. >Languages on the left end of this spectrum require a lot of parsing effort
  22. >    (relatively speaking) ...
  23.  
  24. I once read an article describing REXX's interpreter (REXX is used as both
  25. a "shell" language and an editor extension language), which states that
  26. 20-30% of the CPU time is spent in scanning for the next non-blank ---
  27. something a parser for any language needs to do (this scanner loop is in
  28. tightly coded assembler, by the way).  As the standard method of handling
  29. infix languages is to push things onto a stack, the cost of interpreting
  30. an infix language should be the same as for prefix and postfix languages.
  31. [Sorry, I don't have a reference to the article handy; I think it was by
  32. Auslander, describing a port of REXX from 370 to RT.]
  33.  
  34. [Side note: from my work on a Prolog parser, I can attest that also
  35. allowing user-defined prefix, infix, and postfix operators does not unduly
  36. complicate or slow down the parser.]
  37.  
  38. Let's not push this efficiency argument too far or else we'll see BASIC's
  39. original 1- and 2-letter identifiers resurfacing ... we wouldn't want to
  40. spend too much time in hashing identifiers, would we? :-) Similarly,
  41. there's no reason for the Bourne shell's requirement that functions be
  42. defined before use; REXX easily handles that by recording each function's
  43. location and scanning forward if necessary.  And I strongly suspect that a
  44. properly built interpreter for an infix language would have performance
  45. within a few percent of that for a prefix/postfix language --- and no
  46. question about which is easier to program in.
  47.  
  48. If you want to see REXX's implementation, find somebody who has IBM's CMS
  49. operating system; the interpreter source is included.  [The source for the
  50. compiler and for the OS/2 implementation aren't.]
  51.  
  52. Incidentally, REXX is also evidence that powerful languages don't need to
  53. be cryptic and that they can be used well by both beginners and experts
  54. (REXX has roughly the expressivity of ksh+awk or perl, but with a syntax
  55. like "BASIC done right").
  56.  
  57. -----
  58.  
  59. Peter Ludemann
  60. -- 
  61. Send compilers articles to compilers@iecc.cambridge.ma.us or
  62. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  63.