From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Selecting Components
Date: Sun, 8 Jan 2006 11:58:53 +0100
Date: 2006-01-08T11:58:42+01:00 [thread overview]
Message-ID: <6qjlcxx42apa$.1xcnjep0o3ftw.dlg@40tude.net> (raw)
In-Reply-To: UrVvf.339$Hd4.149@newsread1.news.pas.earthlink.net
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
next prev parent reply other threads:[~2006-01-08 10:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox