From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bd2212324e79c720 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Selecting Components Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Sun, 8 Jan 2006 11:58:53 +0100 Message-ID: <6qjlcxx42apa$.1xcnjep0o3ftw.dlg@40tude.net> NNTP-Posting-Date: 08 Jan 2006 11:58:42 MET NNTP-Posting-Host: 5b1a53df.newsread4.arcor-online.net X-Trace: DXC=\@H:Bo\6X;^XNWN: On Sat, 07 Jan 2006 20:24:20 GMT, Jeffrey R. Carter wrote: > I guess this is primarily aimed at the language lawyers who hang out here. > > Thinking about how Ada selects components of things, especially of composite > objects, I see that almost every case uses dot notation. Package.Declaration, > Record.Component, and so on. The one exception seems to be components of arrays, > which use parentheses: > > Array (Index) > Array (Index_1, Index_2) > Array (High .. Low) Interesting, but I indeed have once used "." notation for array component extraction in a small language I designed. The reason was parsing simplicity. > I suppose one argument for this is that it's how it's always been done since the > earliest days of FORTRAN. Another is that it allows functions to be replaced by > arrays and arrays by functions. > > However, many languages, including Pascal, Ada's ancestor, use [] for array > indices, so the function/array equivalence may not be that strong. > > What would be the consequences if a language were designed so that all > selections used dot notation, including arrays: > > Array.Index > Array.Index_1, Index_2 Not so. Multidimensional array's index is a tuple. So if "." should be the name of indexing operation, then it is always: Array. For a tuple you have to define aggregates. Then it becomes: Array.(Index_1, Index_2) > Array.Low .. High This is a different case. Here "." isn't indexing, but projection, which yields a subarray, maybe of lesser dimension or differently constrained: Array. Of course ranges should be first class citizens for that. ----------- In general, I think that Ada should make indices and sets of indices legal types classes and, of course, expose indexing operations primitive. This would ease a lot of problems, especially in design of container libraries. Having this we could associate indexing with either "()", or "." or whatever operator one wants. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de