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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4afa25b13bea6bcc X-Google-Attributes: gid103376,public From: mfb@mbunix.mitre.org (Michael F Brenner) Subject: Two dimensional arrays: help Date: 1998/01/05 Message-ID: <68qqlp$25v@top.mitre.org>#1/1 X-Deja-AN: 312962902 References: <34B0C8A6.B19098B6@a01-unix.gsyc.inf.uc3m.es> Organization: The MITRE Corporation, Bedford Mass. Newsgroups: comp.lang.ada Date: 1998-01-05T00:00:00+00:00 List-Id: 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