comp.lang.ada
 help / color / mirror / Atom feed
From: "jimmaureenrogers@worldnet.att.net" <jimmaureenrogers@worldnet.att.net>
Subject: Re: Surprise in array concatenation
Date: 5 Sep 2005 10:47:14 -0700
Date: 2005-09-05T10:47:14-07:00	[thread overview]
Message-ID: <1125942434.046551.206180@f14g2000cwb.googlegroups.com> (raw)
In-Reply-To: <1125935610.797293.40550@g43g2000cwa.googlegroups.com>

Gene wrote:
> Thanks for a great discussion.
>
> I didn't say general array indexing is not useful; it obviously is. I
> said it's marginally useful in the literal (economist's) sense of "at
> the margin."  A few illustrations...
>
> 1) If one had to give up a feature in order to get another, many would
> put general array indexing early on the chopping block. Between fixed
> and dynamic length arrays (and in particular bounded/unbounded
> strings), for example, Ada forces one to change from native array
> syntax to a procedural interface that hides re-sizing details.  Ada
> programmers I know would happily give up general index ranges in order
> to get dynamically resizing arrays with native syntax---at least those
> who have worked in other languages where such are available.

What kinds of projects do those Ada programmers work on? Is performance
a critical requirement? Resizable arrays always provide reduced
performance over fixed size arrays. Even worse, the performance
penalties are driven by the data. This makes successful critical timing
consistency impossible when using resizable arrays.

Ada provides three kinds of strings. Those three kinds are not present
merely for convenience. Each type of string represents a trade-off
between efficiency and flexibility. The default fixed string type is
the most efficient and least flexible.

>
> 2) General integer ranges for array indices are a half-hearted---at the
> margins---compromise wrt fully general arrays allowing any type as an
> index.  In other words, if you put
> (A) 1-based arrays,
> (B) general discrete type array indices, and
> (C) fully general arrays
> on a conceptual scale, (B) lies _much_ closer to (A) than to (C).

I disagree completely with what you say. General index types are
popular with scripting languages and a few other new languages.
None of those languages concern them selves with execution efficiency
to the extent that Ada does. None of those languages are useful in
hard real-time systems.

Ada language features have not been added merely for the convenience
of the programmer. The Ada language started with genuine design
requirements. Subsequent refinements of the language have not
abandoned the direction and philosophy expressed through those
requirements.

If you want to use a scripting language such as perl, then use perl.
Do not expect all languages to be scripting languages.

>
> 3) The wonder of Ada is the predicatable, orthogonal way that syntax
> and semantics correspond.  But we have just been observing that general
> integer array indexing leads to a not-very-predictable behavior in
> combination with slicing and catenation. If all arrays were 1-based,
> the problem could not have occurred.  Hence this unhappy confluence of
> features, by conflicting with Ada's philosophy, is at the semantic
> margins of the language.  It ought to be avoided if the goal is code
> with obvious meaning. E.g. after I re-coded my original example
> "properly" with 'First and 'Range to make its behavior correct, I
> quickly added a comment, -- 'First is not always 1.  How marginally
> Ada!

In fact the Ada approach is always predictable with regard to slicing
and concatenation. Your experience appears to be rooted in languages
with a different concept of type. For instance, C and C++ have no
array types. One can define an array in each of those languages, but
there is no type tag associated with such an array. One cannot look
up the name of an array type in a C or C++ symbol table.

Ada provides array types. Ada also provides subtypes. Every instance
of an unconstrained array type is constrained. Likewise, every
instance of an unconstrained array type represents a subtype of the
parent unconstrained array type.

All these bits of information are necessary for understanding Ada array
slicing and concatenation. Every Ada array and array slice has a set of
index values. Slicing an array does not "convert" the index values from
their original set to an equivalent size set beginning at 1, 0, or any
other value you might choose. The slice forms a view into the array
from which the slice is taken. It is quite logical, and not the least
marginal, that this view should maintain consistency in its
representation.  When concatenating two arrays, the language must
join the sets of indices in a continuous set of values. Your original
posting marveled that the joining of an empty array with a slice
not starting at 1 resulted in an array whose 'First value was the
same as the slice. Concatenating array A whose indices represent
the null set with array B whose indices represent some non-null set
should always result in an array whose indices are a non-null set.
Moreover, the most efficient and logical merging of the two sets
results in a set idenitcal to the indices of B.

Jim Rogers




  reply	other threads:[~2005-09-05 17:47 UTC|newest]

Thread overview: 108+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-01  3:16 Surprise in array concatenation Gene
2005-09-01  7:55 ` Dmitry A. Kazakov
2005-09-01  8:02   ` Florian Weimer
2005-09-01 11:48     ` Georg Bauhaus
2005-09-01 12:02       ` Lutz Donnerhacke
2005-09-01 13:01         ` Georg Bauhaus
2005-09-01 15:54       ` Florian Weimer
2005-09-01 16:09     ` Robert A Duff
2005-09-05  8:38       ` Jean-Pierre Rosen
2005-09-05 23:52         ` Robert A Duff
2005-09-06  9:03           ` Jean-Pierre Rosen
2005-09-07 17:57         ` adaworks
2005-09-07 20:01           ` Robert A Duff
2005-09-08  8:08             ` Jacob Sparre Andersen
2005-09-07 22:46           ` Jeffrey Carter
2005-09-08  4:43             ` Simon Wright
2005-09-08 10:36               ` Georg Bauhaus
2005-09-08 13:47                 ` Ed Falis
2005-09-08 17:03                   ` Pascal Obry
2005-09-08 16:45               ` Jeffrey Carter
2005-09-08 19:37                 ` Simon Wright
2005-09-08  6:32             ` adaworks
2005-09-08  9:09               ` Jean-Pierre Rosen
2005-09-08 16:56               ` Jeffrey Carter
2005-09-09 14:04                 ` Bob Spooner
2005-09-09 16:17                 ` adaworks
2005-09-23 23:04               ` Randy Brukardt
2005-09-14  8:57           ` Ole-Hjalmar Kristensen
2005-09-23 23:09           ` Randy Brukardt
2005-09-24 10:49             ` Larry Kilgallen
2005-09-24 20:27             ` Lurker
2005-09-25  0:20             ` Robert A Duff
2005-09-25 17:05             ` adaworks
2005-09-01 11:42   ` Georg Bauhaus
2005-09-01 13:59     ` Dmitry A. Kazakov
2005-09-01 15:36       ` Georg Bauhaus
2005-09-01 18:34         ` Dmitry A. Kazakov
2005-09-02 10:43           ` Georg Bauhaus
2005-09-02 13:11             ` Dmitry A. Kazakov
2005-09-02 14:23               ` Georg Bauhaus
2005-09-02 19:48                 ` Dmitry A. Kazakov
2005-09-02 17:21           ` Björn Persson
2005-09-01 16:04   ` Robert A Duff
2005-09-01 18:06     ` Dmitry A. Kazakov
2005-09-02 10:42       ` Georg Bauhaus
2005-09-02 13:20         ` Dmitry A. Kazakov
2005-09-02 14:14           ` Georg Bauhaus
2005-09-02 19:48             ` Dmitry A. Kazakov
2005-09-03 20:01               ` Georg Bauhaus
2005-09-04 10:13                 ` Dmitry A. Kazakov
2005-09-05 13:22                   ` Georg Bauhaus
2005-09-05 15:50                     ` Dmitry A. Kazakov
2005-09-05 18:20                       ` Georg Bauhaus
2005-09-05 18:31                         ` Georg Bauhaus
2005-09-06  8:20                         ` Dmitry A. Kazakov
2005-09-06 11:52                           ` Georg Bauhaus
2005-09-06 13:46                             ` Dmitry A. Kazakov
2005-09-06 15:51                               ` Georg Bauhaus
2005-09-06 21:32                                 ` Robert A Duff
2005-09-07  9:08                                 ` Dmitry A. Kazakov
2005-09-07 18:20                                   ` Georg Bauhaus
2005-09-07 19:07                                     ` Georg Bauhaus
2005-09-07 21:23                                     ` Dmitry A. Kazakov
2005-09-08 10:27                                       ` Georg Bauhaus
2005-09-08 11:39                                         ` Georg Bauhaus
2005-09-08 13:44                                         ` Dmitry A. Kazakov
2005-09-08 18:18                                           ` Georg Bauhaus
2005-09-09 10:06                                             ` Dmitry A. Kazakov
2005-09-09 12:26                                               ` Georg Bauhaus
2005-09-09 12:29                                               ` Georg Bauhaus
2005-09-01  8:48 ` Jean-Pierre Rosen
2005-09-01 15:57 ` Robert A Duff
2005-09-01 21:42   ` Gene
2005-09-01 22:56     ` tmoran
2005-09-05 15:53       ` Gene
2005-09-05 17:47         ` jimmaureenrogers [this message]
2005-09-05 22:13           ` Robert A Duff
2005-09-06  8:24             ` Dmitry A. Kazakov
2005-09-05 19:22         ` Jeffrey R. Carter
2005-09-05 21:54           ` Robert A Duff
2005-09-05 22:50             ` Larry Kilgallen
2005-09-05 23:46               ` Robert A Duff
2005-09-12  3:59                 ` Dave Thompson
2005-09-06 16:02             ` Jeffrey Carter
2005-09-06 21:00               ` Robert A Duff
2005-09-06  5:38         ` Pascal Obry
2005-09-05 21:48       ` Robert A Duff
2005-09-06  5:25         ` tmoran
2005-09-06 14:58           ` Robert A Duff
2005-09-06  9:26         ` Georg Bauhaus
2005-09-06 15:00           ` Robert A Duff
2005-09-07 11:02             ` Thierry Pirot
2005-09-07 20:09               ` Robert A Duff
2005-09-06 13:22         ` Bob Spooner
2005-09-06 15:30           ` Robert A Duff
2005-09-06 16:12             ` Jeffrey Carter
2005-09-06 21:21               ` Robert A Duff
2005-09-02 20:19     ` Jeffrey R. Carter
2005-09-03 12:51     ` Dr. Adrian Wrigley
2005-09-03 14:08       ` Jacob Sparre Andersen
2005-09-05  8:34         ` Jean-Pierre Rosen
2005-09-05  9:32           ` Arrays indexed by fixed point types (Was: Surprise in array concatenation) Jacob Sparre Andersen
2005-09-05 11:07             ` Jean-Pierre Rosen
2005-09-05 15:12               ` Dr. Adrian Wrigley
2005-09-05 12:14             ` Dmitry A. Kazakov
2005-09-05 13:07               ` Jacob Sparre Andersen
2005-09-05 15:10                 ` Dmitry A. Kazakov
2005-09-05 11:29           ` Surprise in array concatenation Dr. Adrian Wrigley
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox