comp.lang.ada
 help / color / mirror / Atom feed
From: mfb@mbunix.mitre.org (Michael F Brenner)
Subject: Two dimensional arrays: help
Date: 1998/01/05
Date: 1998-01-05T00:00:00+00:00	[thread overview]
Message-ID: <68qqlp$25v@top.mitre.org> (raw)
In-Reply-To: dewar.884005840@merv


In any computer language or other artistic endeavor, one of the easiest
ways to learn the rules is by examples. In many cases the rules are
so culturally specific that outsiders actually benefit more from
working examples than from the rules at all. In addition, when the rules
change (noteable examples are the loss of efficiency introduced into
unsigned numbers between the rationale and the manual, and the 
inconsistency accepted as normal in the ways that stream_io works
on different current versions of gnat), it is impossible to know
the rules except by having access to working examples.

The Ada community would benefit by a set of working examples
for each feature of the language. The Ada restrictions on two 
dimensional arrays are such that one can program them successfully
from an example, but it would be MUCH less efficient to attempt
to learn them from the rules in the rationale and the manual. 
This is in part a fault of the rules, in part a fault of the
intended design of the language to introduce artificial
restrictions in the name of readability, and in part a fault
of the expression of the rules. In particular the expression
of the rules would be Greatly enhanced by putting the set of
working examples directly hypertext linked into the next 
version of the manual in a way that they can be compiled and
run. 

The lack of examples, particularly of two dimensional arrays of
packed bits, where efficiency is not only paramount, it is the
only criteria for choice of language used, is the cause of 
so many Ada compilers getting that part of the language working
last. If examples of packed bit strings were emphasized more
in the validation suites, so that almost no test could pass until
packed bits strings worked, then the compilers would be validated
with less cost and have a lot less future maintenance.

The old way of remembering that FORTRAN matrices go one way and
math book matrices go the other way does not work with Ada, 
which introduces a whole new vocabulary for its two dimensional
arrays. The correct way to describe matrices is geometrically,
with horizontal x coordinates and vertical y coordinates, like
on a printer or screen. It is not a trivial task to use the
manual to derive the rules for using two dimensional arrays in
Ada (assuming you are familiar with two dimensional arrays in
say, FORTRAN, Pascal, or some other language). An example of
actual use, that is, a working example, however, is instantly
easy to see how to define, initialize, and use the two dimensional
array.

Therefore, I have sent an e-mail to you with an example that
defines, initializes, makes use of a two dimensional array to
implement the transition matrix of a finite state machine that you
can compile, link, run, and use as a model of how to program
two dimensional arrays.

After you get your first program up and running, then I recommend
that you follow Robert's suggestion to read the on-line
manuals, rationale, etc., available on the Net.

Mike Brenner




  reply	other threads:[~1998-01-05  0:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-01-05  0:00 About a C/C++ to ADA translator Marcos Jimenez Bermejo
1998-01-05  0:00 ` Robert Dewar
1998-01-05  0:00   ` Michael F Brenner [this message]
1998-01-05  0:00     ` Two dimensional arrays: help Robert Dewar
1998-01-06  0:00       ` Chris Morgan
1998-01-06  0:00         ` Robert Dewar
1998-01-05  0:00   ` About a C/C++ to ADA translator Marcos Jimenez Bermejo
1998-01-05  0:00     ` Kenneth W. Sodemann
1998-01-05  0:00     ` nabbasi
1998-01-05  0:00 ` David  Weller
1998-01-05  0:00   ` Robert Dewar
1998-01-07  0:00 ` Benoit Jauvin-Girard
1998-01-12  0:00   ` Jean-Claude MAHIEUX
1998-01-09  0:00 ` Brian G. Holmes
replies disabled

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