home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / arch / 10917 < prev    next >
Encoding:
Internet Message Format  |  1992-11-19  |  2.6 KB

  1. Xref: sparky comp.arch:10917 comp.lang.misc:3790
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!usenet.coe.montana.edu!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!netnews-2.srv.cs.cmu.edu!moss
  3. From: moss@cs.cmu.edu (Eliot Moss)
  4. Newsgroups: comp.arch,comp.lang.misc
  5. Subject: Re: adding new operators on the fly
  6. Message-ID: <MOSS.92Nov19094411@CRAFTY.cs.cmu.edu>
  7. Date: 19 Nov 92 14:44:11 GMT
  8. Article-I.D.: CRAFTY.MOSS.92Nov19094411
  9. References: <1992Nov13.155126.3660@linus.mitre.org> <722061125@sheol.UUCP>
  10.     <1992Nov18.212323.15324@newshost.lanl.gov>
  11. Sender: news@cs.cmu.edu (Usenet News System)
  12. Reply-To: moss@cs.cmu.edu
  13. Organization: Dept of Comp and Info Sci, Univ of Mass (Amherst)
  14. Lines: 42
  15. In-Reply-To: jlg@cochiti.lanl.gov's message of Wed, 18 Nov 1992 21:23:23 GMT
  16. Nntp-Posting-Host: crafty.fox.cs.cmu.edu
  17.  
  18. I contend that when adding new operators it is much too confusing to allow the
  19. user to choose/define precedence (at least), thoough associativity and
  20. commutativity are less of a problem. The point is that it gets too complicated
  21. for someone trying the READ the program and understand it. Rather, it is
  22. likely better to take the approach of APL and Smalltalk: define one simple
  23. evaluation order and otherwise require parenthesization. In APL I believe
  24. evaluation is right to left; in Smalltalk it is only slightly more
  25. complicated. There are three kinds of operators: unary postfix, binary infix,
  26. and keyword "mixfix". The unary ones are simple identifiers, for example:
  27.  
  28.     17 negate
  29.  
  30. The binary ones are formed from a set of "special" characters, and consist of
  31. one or two (maybe even three; I'm doing this from memory) characters from that
  32. set. Examples are:
  33.  
  34.     x + y
  35.     y << 3
  36.  
  37. Finally, keyword operators consist of a sequence of one or more identifiers,
  38. each followed by a colon; if there are K identifiers, then there must be K+1
  39. subexpressions, with the pieces of the operators inserted between the
  40. expressions. For example:
  41.  
  42.     x at: 17
  43.     x at: 17 put: y
  44.  
  45. The evaluation rule is unary, then binary, then keyword (unless parentheses
  46. further delimit the expression). One DOES get used to this fairly quickly.
  47.  
  48. Finally, I suggest further discussion of this topic be moved out of comp.arch,
  49. since it is a language/compiler issue, not fundamentally one of computer
  50. architecture.
  51. --
  52.  
  53. J. Eliot B. Moss, Associate Professor    Visiting Associate Professor
  54. Department of Computer Science        School of Computer Science
  55. Lederle Graduate Research Center    Carnegie Mellon University
  56. University of Massachusetts        5000 Forbes Avenue
  57. Amherst, MA  01003            Pittsburgh, PA  15213-3891
  58. (413) 545-4206, 545-1249 (fax)        (412) 268-6767, 681-5739 (fax)
  59. Moss@cs.umass.edu            Moss@cs.cmu.edu
  60.