home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / std / cplus / 1188 < prev    next >
Encoding:
Internet Message Format  |  1992-09-15  |  2.3 KB

  1. Xref: sparky comp.std.c++:1188 comp.lang.c++:13692
  2. Newsgroups: comp.std.c++,comp.lang.c++
  3. Path: sparky!uunet!mcsun!news.funet.fi!cc.tut.fi!jk87377
  4. From: jk87377@cc.tut.fi (Juhana Kouhia)
  5. Subject: Re: Exponentiation operator proposal
  6. Message-ID: <1992Sep15.173259.28758@cc.tut.fi>
  7. Organization: Tampere University of Technology
  8. References: <HBF.92Sep14205333@durin.uio.no> <1992Sep15.054226.4126@cc.tut.fi> <1992Sep15.140027.17387@sunb10.cs.uiuc.edu>
  9. Date: Tue, 15 Sep 92 17:32:59 GMT
  10. Lines: 59
  11.  
  12.  
  13. In article <1992Sep15.140027.17387@sunb10.cs.uiuc.edu>
  14. pjl@sparc10.cs.uiuc.edu (Paul Lucas) writes:
  15. >In <1992Sep15.054226.4126@cc.tut.fi> jk87377@cc.tut.fi (Juhana
  16. >Kouhia) writes:
  17. >
  18. >>Instead of making exponential operator; I would like to get
  19. >>a new basic operation which allows programmer to define new
  20. >>operations like 'a ** b'; that is, the '**' is defined.
  21. >>('a pow b' is also good.)
  22. >
  23. >*****>    The short answer is that it's a _real_ pain.  The somewhat
  24. >    longer answer is that making new operators means that you have
  25. >    to also establish the precedence and associativity of the new
  26. >    operator relative to all the other operators *AND* any other
  27. >    operators created by other people.  Every time an operator is
  28. >    added, the hierarchy would have to be readjusted.
  29.  
  30. I didn't thought this. 
  31.  
  32. >    For new operators, the precedence and associativity may seem
  33. >    arbitary at the time of creation
  34.  
  35. At the compile time; just like functions are created.
  36. Am I missing something? In what order the compiling the X and
  37. the Y happens?
  38.  
  39. If X and Y provides the same function with different meanings,
  40. how this is handled? I think the same apply to new operation.
  41. That is, compile time error.
  42. The same scope rules apply to the new operation too.
  43.  
  44. Lets suppose both X and Y makes the new operation to the
  45. default operation precedence and associativity data set.
  46. If they both offers the same operation, it is compile time error.
  47. If both offers different operations, then this is valid.
  48. But how to make the common operation predence and associativity
  49. data set? I have to think about this a bit.
  50. Just by adding the both operations to the same level?
  51. For example,
  52.  
  53. Default set:
  54. Level 1: * /
  55. Level 2: + -
  56.  
  57. X:
  58. Level 1: * / foo
  59. Level 2: + -
  60.  
  61. Y:
  62. Level 1: * /
  63. Level 2: + - bar
  64.  
  65. The common set:
  66. Level 1: * / foo
  67. Level 2: + - bar
  68.  
  69.  
  70.  
  71. Juhana Kouhia
  72.