home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 16150 < prev    next >
Encoding:
Internet Message Format  |  1992-11-12  |  1.7 KB

  1. Path: sparky!uunet!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb
  2. From: tmb@arolla.idiap.ch (Thomas M. Breuel)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: operator [][]
  5. Date: 12 Nov 92 11:56:39
  6. Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
  7.     Perceptive)
  8. Lines: 29
  9. Message-ID: <TMB.92Nov12115639@arolla.idiap.ch>
  10. References: <BxFt8r.2Kt@cs.columbia.edu> <1992Nov9.095352.19114@fmrco.uucp>
  11.     <1992Nov9.114516.29846@alf.uib.no>
  12.     <1992Nov11.182016.13511@ucc.su.OZ.AU>
  13. Reply-To: tmb@idiap.ch
  14. NNTP-Posting-Host: arolla.idiap.ch
  15. In-reply-to: maxtal@extro.ucc.su.OZ.AU's message of Wed, 11 Nov 1992 18:20:16 GMT
  16.  
  17. In article <1992Nov11.182016.13511@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  18.  
  19.        It would be nice if [] could work like (), that is one could
  20.    declared
  21.  
  22.        operator[](int,int,int){ ...}
  23.  
  24.    for example, that is, allow multiple arguments for [] just like ().
  25.    This would allow multiple dimensioned matrices as well as providing
  26.    a wealth of extra overloadable notations.
  27.  
  28.    It would of course break those programs for which
  29.  
  30.        a[2,3];
  31.  
  32.    actually meant a[3] using the comma operator, but there surely are not
  33.    so many of them ..??
  34.  
  35. Well, in principle that ambiguity is resolvable: you use the
  36. "operator[](int,int)" interpretation only if such an operator is
  37. actually defined. Of course, that would make parsing and compiling
  38. even messier than it is now (think about templates...).
  39.  
  40. Altogether, we will probably just have to continue to live with what
  41. is there.  I have been using "operator[]" less and less in my code
  42. (only for 1D collections) and have been relying on "operator()" or
  43. member functions ("foo.sub(x,y)") instead.
  44.  
  45.                     Thomas.
  46.