home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / misc / 3746 < prev    next >
Encoding:
Text File  |  1992-11-17  |  3.5 KB  |  63 lines

  1. Newsgroups: comp.lang.misc
  2. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!agate!spool.mu.edu!news.nd.edu!mentor.cc.purdue.edu!pop.stat.purdue.edu!hrubin
  3. From: hrubin@pop.stat.purdue.edu (Herman Rubin)
  4. Subject: Re: how to advocate new software/hardware features (Re: Hardware Support for Numeric Algorithms)
  5. Message-ID: <Bxvs9I.L22@mentor.cc.purdue.edu>
  6. Sender: news@mentor.cc.purdue.edu (USENET News)
  7. Organization: Purdue University Statistics Department
  8. References: <TMB.92Nov16140138@arolla.idiap.ch> <BxtFoF.BGn@mentor.cc.pur <KERS.92Nov17090305@cdollin.hpl.hp.com>
  9. Date: Tue, 17 Nov 1992 22:10:30 GMT
  10. Lines: 51
  11.  
  12. In article <KERS.92Nov17090305@cdollin.hpl.hp.com> kers@hplb.hpl.hp.com (Chris Dollin) writes:
  13. >I've (tried to) direct followups away from comp.arch.
  14.  
  15. >In article ... tmb@arolla.idiap.ch (Thomas M. Breuel) writes:
  16.  
  17. >   The problem is that user-defined operators cause problems about which
  18. >   the compiler cannot warn reliably. For the rationale and some examples
  19. >   of what can go wrong, see the ARM, p331.
  20.  
  21. >It says ``This extension, however, would imply a significant extension of
  22. >complexity of syntax analysis and an uncertain gain in readability.'' It then
  23. >remarks that precedence and associativity must either be fixed for all
  24. >user-defined operators, or a mechanism must be present to define them; it is
  25. >this latter that is the tricky point. (The ``complexity of syntax analysis''
  26. >argument seems to be terribly weak, given that (a) Stroustrup is not stupid,
  27. >and (b) the rest of C++.)
  28.  
  29. >There are many other things compilers cannot warn about reliably, or indeed, at
  30. >all; writing ``-'' when one meant ``+'', forgetting to increment a counter,
  31. >calling the wrong function (or not calling the right one), writing ``0'' when
  32. >style demands FALSE or NULL_String, and so on. Has anyone done some *research*
  33. >on the issue, rather than making *-informed speculation?
  34.  
  35. >[My own speculation is that it's all perfectly sensible provided you're
  36. >prepared to forgo the ability to define your own precedence and associativity,
  37. >and that operator tokens are recognisable by spelling just as identifiers are.
  38. >What would be handy, I think, is a way of making *any* dyadic function into an
  39. >infix with a simple syntactic mark, eg, ``E1 @F E2''.]
  40.  
  41. The precedence problem was actually aggravated by C, and I suspect that it
  42. is necessary to do some pulling back.  The user who has not run into the
  43. specific situation is likely to get a rather large number of the precedences
  44. wrong.  What is the correct association in a << b + c?  Everyone I showed 
  45. this to came up with the same answer; but that answer is wrong in C!  One
  46. cannot even get the compiler to consider spacing in resolving this.  I 
  47. would just as soon go the the APL idea, which only distinguishers unary
  48. and binary.  It would help if we could get a more complicated set of 
  49. parentheses, or allow explicit temporaries to be used to break up the
  50. operation stream; this would certainly be needed if functions produced
  51. a list of results.
  52.  
  53. I agree that this complexity of syntax analysis is very weak.  Put one
  54. precedence for unary operators and another for binary operators, or even
  55. equate the infix notation x FOO y with !FOO(x,y); those of us who want 
  56. to use user-defined operators would find this a lot preferable to not
  57. allowing them at all, even if we had to use parentheses all the time.
  58. -- 
  59. Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907-1399
  60. Phone: (317)494-6054
  61. hrubin@snap.stat.purdue.edu (Internet, bitnet)  
  62. {purdue,pur-ee}!snap.stat!hrubin(UUCP)
  63.