* Selecting Components @ 2006-01-07 20:24 Jeffrey R. Carter 2006-01-08 1:09 ` (see below) ` (3 more replies) 0 siblings, 4 replies; 9+ messages in thread From: Jeffrey R. Carter @ 2006-01-07 20:24 UTC (permalink / raw) 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) 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 Array.Low .. High ? -- Jeff Carter "Spam! Spam! Spam! Spam! Spam! Spam! Spam! Spam!" Monty Python's Flying Circus 53 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Selecting Components 2006-01-07 20:24 Selecting Components Jeffrey R. Carter @ 2006-01-08 1:09 ` (see below) 2006-01-08 6:18 ` Jeffrey R. Carter 2006-01-08 20:35 ` Keith Thompson 2006-01-08 10:58 ` Dmitry A. Kazakov ` (2 subsequent siblings) 3 siblings, 2 replies; 9+ messages in thread From: (see below) @ 2006-01-08 1:09 UTC (permalink / raw) On 7/1/06 20:24, in article UrVvf.339$Hd4.149@newsread1.news.pas.earthlink.net, "Jeffrey R. Carter" <spam@spam.com> wrote: > 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 > Array.Low .. High The consequence would be ambiguous arithmetic expressions. Consider: Array.Index + 1 is this (Array.Index)+1 or Array.(Index+1)? -- Bill Findlay <surname><forename> chez blueyonder.co.uk ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Selecting Components 2006-01-08 1:09 ` (see below) @ 2006-01-08 6:18 ` Jeffrey R. Carter 2006-01-08 20:35 ` Keith Thompson 1 sibling, 0 replies; 9+ messages in thread From: Jeffrey R. Carter @ 2006-01-08 6:18 UTC (permalink / raw) (see below) wrote: > > Consider: > > Array.Index + 1 > > is this (Array.Index)+1 or Array.(Index+1)? Certainly that would have to be defined. -- Jeff Carter "I soiled my armor, I was so scared." Monty Python & the Holy Grail 71 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Selecting Components 2006-01-08 1:09 ` (see below) 2006-01-08 6:18 ` Jeffrey R. Carter @ 2006-01-08 20:35 ` Keith Thompson 1 sibling, 0 replies; 9+ messages in thread From: Keith Thompson @ 2006-01-08 20:35 UTC (permalink / raw) "(see below)" <yaldnif.b@blueyonder.co.uk> writes: > On 7/1/06 20:24, in article > UrVvf.339$Hd4.149@newsread1.news.pas.earthlink.net, "Jeffrey R. Carter" > <spam@spam.com> wrote: > >> 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 >> Array.Low .. High > > The consequence would be ambiguous arithmetic expressions. > > Consider: > > Array.Index + 1 > > is this (Array.Index)+1 or Array.(Index+1)? Presumably it would be (Array.Index) + 1; there's no reason for "." to have a different precedence for arrays than for records. There's a visual ambiguity: does Foo.Bar mean the Bar'th element of the array Foo, or the component Bar of the record Foo? This is of course resolved by the type of Foo (unless Foo is an overloaded function), but what's easy for the compiler may be difficult for a human reader. -- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> We must do something. This is something. Therefore, we must do this. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Selecting Components 2006-01-07 20:24 Selecting Components Jeffrey R. Carter 2006-01-08 1:09 ` (see below) @ 2006-01-08 10:58 ` Dmitry A. Kazakov 2006-01-09 0:12 ` Georg Bauhaus 2006-01-11 2:29 ` Stephen Leake 3 siblings, 0 replies; 9+ messages in thread From: Dmitry A. Kazakov @ 2006-01-08 10:58 UTC (permalink / raw) 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.<index> 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.<index-subset> 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Selecting Components 2006-01-07 20:24 Selecting Components Jeffrey R. Carter 2006-01-08 1:09 ` (see below) 2006-01-08 10:58 ` Dmitry A. Kazakov @ 2006-01-09 0:12 ` Georg Bauhaus 2006-01-09 4:41 ` Jeffrey R. Carter 2006-01-11 2:29 ` Stephen Leake 3 siblings, 1 reply; 9+ messages in thread From: Georg Bauhaus @ 2006-01-09 0:12 UTC (permalink / raw) On Sat, 2006-01-07 at 20:24 +0000, Jeffrey R. Carter wrote: > 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 > Array.Low .. High Interesting. Is "Index_1, Index_2" and expression, or an identifier as in Pack.Op, Rec.Comp, etc.? with Index; ... declare Index: ... begin for k in a'range loop Result := Result + a.Index.k; end loop; end; For the record, in Eiffel you'd write array @ expr, Haskell uses array !! expr. Eiffel uses '.' for object.feature, not as an operator. Haskell uses '.' for function composition, too, if surrounded by white space. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Selecting Components 2006-01-09 0:12 ` Georg Bauhaus @ 2006-01-09 4:41 ` Jeffrey R. Carter 0 siblings, 0 replies; 9+ messages in thread From: Jeffrey R. Carter @ 2006-01-09 4:41 UTC (permalink / raw) Georg Bauhaus wrote: > > Interesting. > Is "Index_1, Index_2" and expression, or an identifier > as in Pack.Op, Rec.Comp, etc.? Array.Index_1, Index_2 would be equivalent to Ada's Array (Index_1, Index_2), where "Array" represents a 2D array object. -- Jeff Carter "All citizens will be required to change their underwear every half hour. Underwear will be worn on the outside, so we can check." Bananas 29 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Selecting Components 2006-01-07 20:24 Selecting Components Jeffrey R. Carter ` (2 preceding siblings ...) 2006-01-09 0:12 ` Georg Bauhaus @ 2006-01-11 2:29 ` Stephen Leake 2006-01-11 3:01 ` Jeffrey R. Carter 3 siblings, 1 reply; 9+ messages in thread From: Stephen Leake @ 2006-01-11 2:29 UTC (permalink / raw) "Jeffrey R. Carter" <spam@spam.com> writes: > 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 > Array.Low .. High Mass confusion. No new software is written. All trains stop running. No food is delivered. All die. Oh, the embarrassment :). -- -- Stephe ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Selecting Components 2006-01-11 2:29 ` Stephen Leake @ 2006-01-11 3:01 ` Jeffrey R. Carter 0 siblings, 0 replies; 9+ messages in thread From: Jeffrey R. Carter @ 2006-01-11 3:01 UTC (permalink / raw) Stephen Leake wrote: > Mass confusion. > > No new software is written. > > All trains stop running. > > No food is delivered. > > All die. > > Oh, the embarrassment :). You say that as if it were a bad thing. -- Jeff Carter "Run away! Run away!" Monty Python and the Holy Grail 58 ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2006-01-11 3:01 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2006-01-07 20:24 Selecting Components Jeffrey R. Carter 2006-01-08 1:09 ` (see below) 2006-01-08 6:18 ` Jeffrey R. Carter 2006-01-08 20:35 ` Keith Thompson 2006-01-08 10:58 ` Dmitry A. Kazakov 2006-01-09 0:12 ` Georg Bauhaus 2006-01-09 4:41 ` Jeffrey R. Carter 2006-01-11 2:29 ` Stephen Leake 2006-01-11 3:01 ` Jeffrey R. Carter
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox