Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!husc6!mit-eddie!ganymede.UUCP!tmb From: tmb@ganymede.UUCP Newsgroups: comp.lang.c++ Subject: Declaration of multi-dimensional arrays. Message-ID: <8809040943.AA28707@rice-chex.ai.mit.edu> Date: 4 Sep 88 09:43:19 GMT Sender: daemon@eddie.MIT.EDU Lines: 32 >From @rome.ics.uci.edu:schmidt@harlie.ics.uci.edu Sun Sep 4 01:20:24 1988 remote from ai-lab From: "Douglas C. Schmidt" Section 1.13 of Stroustrup (pages 30-32) describe the development of a vector type. On page 32 Stroustrup remarks ``It is quite simple to provide multi-dimensional arrays, [etc].'' However, is it correct to state that these multi-dimensional arrays require a functional syntax, i.e., foo(i,j,k), rather than an extension of the ``operator[]'' concept to multiple dimensions, e.g., foo[i][j][k]? In other words, in G++, at least, it does not seem possible to overload the [] notation for more than a single dimension. Is this a deliberate decision based upon the C++ reference manual, a difficult semantic/syntactic construct, or simply an unimplemented feature in G++? Let me quote from a recent paper: "We would like to see multidimensional subscripting added to the C++ language, i.e. to allow the programmer to overload {\tt operator[]} with multiple arguments. This would require the programmer to parenthesize expressions containing the ``,'' operator inside the subscripting operator, an incompatible but minor change in the syntax of the language." You could use functional syntax, but somehow that doesn't seem appropriate. After all, all of this is a question of syntactic sugar, and if you don't care about whether it's pretty, you might as well write "ref(foo,i,j,k)" and forget about the operator notation altogether. Thomas.