home *** CD-ROM | disk | FTP | other *** search
- 5-Jun-86 18:18:59-MDT,1410;000000000011
- Return-Path: <dritz@anl-mcs.ARPA>
- Received: from anl-mcs.ARPA by SIMTEL20.ARPA with TCP; Thu 5 Jun 86 18:18:54-MDT
- Received: by anl-mcs.ARPA (4.12/4.9)
- id AA26714; Thu, 5 Jun 86 19:18:26 cdt
- Date: Thu, 5 Jun 86 19:18:26 cdt
- From: dritz@anl-mcs.ARPA (Kenneth W. Dritz)
- Message-Id: <8606060018.AA26714@anl-mcs.ARPA>
- To: rconn@simtel20.arpa
- Subject: pd:<ada.ai>alspdesgn.doc.1
- Cc: dritz@anl-mcs.ARPA
-
- Rick,
-
- I copied pd:<ada.ai>alsp* to my machine with ftp and then browsed through
- the files. The file alspdesgn.doc.1 might as well be omitted, since it
- is included as part of alsptech.doc.1 (with a trivial change on the cover
- page and in the description of the purpose of the document on page 1). The
- latter document is actually a concatenation of two documents, the first of
- which is the design specification and the last of which is the final technical
- report. Either of two things could be done to eliminate the redundancy:
- (1) Delete the former document and leave only the latter, or (2) replace
- the latter document by the final technical report "subdocument" contained
- in it. The submittors should be consulted to determine if one of these
- is acceptable.
-
- If I can find a little time, I'll try to compile and execute the source
- on the Verdix compiler on our Sequent. If the results are noteworthy, I'll
- post them to the net. ---Ken Dritz (Dritz @ anl-mcs.arpa)
- -------------------------------------------------------------------------
- Date: Tue, 1 Sep 87 17:23:27 cdt
- From: dritz@anl-mcs.ARPA (Kenneth W. Dritz)
- To: rconn@simtel20.arpa
- Subject: Comments on PD:<ADA.AI>ALSPTYPES.SRC
-
- Over a year ago I submitted a trivial comment about the Lisp/Ada AI types
- package (files PD:<ADA.AI>ALSP*). That comment, which has been stored
- in the repository as PD:<ADA.AI>ALSP.CM2, indicated that I would
- evaluate the submission, ALSPTYPES.SRC, and comment further once I had
- time to do so. At long last, here it is.
-
- Indeed, I compiled and tried to execute the demonstration program
- shortly after my previous note. I encountered several difficulties,
- most of which I was able to circumvent. One, however, was a case of
- bad code generation by the compiler I was using, which stopped me
- dead. Our compiler is Sequent's port of the Verdix VADS (Verdix Ada
- Development System). At the time of my first test, the version was 5.2
- (or 5.2a). We have only recently formalized our support agreement with
- Verdix and obtained an updated version (5.41) of the VADS. This
- current version corrects the bad-code-generation bug and allows me to
- obtain a useful execution of the demonstration program.
-
- In short, the circumventable difficulties persist, but once they have
- been circumvented execution appears to be normal, or at least as
- expected with a very limited number of examples tried. I'll discuss
- the difficulties below.
-
- Another commenter has reviewed this same submission (see file
- PD:<ADA.AI>ALSP.CMM) and reported no problems of any sort. Note that
- that reviewer tested the submission in the same environment (DEC) in
- which the submission was developed, so the fact that no problems were
- encountered is not surprising.
-
- The first problem is that one of the units of the submission, the
- package body for the package named AI_Data_Types, "with"s a package
- that is not supplied and not a standard package. Specifically, it
- "with"s Integer_Text_Io. I assumed that Integer_Text_Io is an
- instantiation of Text_Io.Integer_Io for type Integer, and that either
- DEC supplies such a pre-instantiated package or the developing
- institution maintains one. My assumption about what Integer_Text_Io
- is supposed to be was apparently correct, since with the obvious
- circumvention the problem was overcome successfully. With but one or
- two lines of change in the component submitted to the repository, it
- would have been more portable. (I'm guessing that this is a fairly
- common problem.)
-
- The second problem is somewhat messier. In several of the units of the
- submission, record types with variant parts are declared with variants
- like this:
-
- when Var5 => Var5 : String (1 .. 5);
-
- Here, the first instance of "Var5" is an enumeration literal of an
- enumeration type declared elsewhere, while the second instance of
- "Var5" is to be the name of the component declared by the component
- declaration contained in the variant. The VADS interprets the first
- instance of Var5 as the name of the component, not the enumeration
- literal, and in this context the name of the component is not allowed.
- The error diagnostic ("component cannot be used inside its own record")
- refers to RM 3.7(3).
-
- Since the DEC compiler accepts this, it is possibly a bug in the
- Verdix compiler; alternatively, if the Verdix compiler is correct,
- then the DEC compiler is wrong for failing to catch a program error.
- After reading the rules for declarative regions and scopes, I am
- inclined to believe the DEC compiler is right. I will submit this to
- Verdix and report the results here later.
-
- To circumvent this problem I changed the source to use different names
- for the enumeration literals and the record components.
-
- Although these are the only problems I encountered in testing the
- submission, I'd like to comment on something else in the author's
- submitted source code and documentation. In ALSPDESGN.DOC and
- ALSPTECH.DOC the author comments that integer overflow (Numeric_Error
- exception) during execution, in the DEC system, prevented the
- declaration of a "dynamic string" type in the "obvious" way, e.g., as
-
- type Dyn_String (Length : Natural := 80) is
- record
- Dyn_Str : String (1 .. Length);
- end record;
-
- The author circumvented this problem by the kludgy technique of
- (paraphrasing here; these are not the names the author used)
-
- type Length_Type is (Var1, Var2, ..., Var15);
- type Dyn_String (Kind : Length_Type := Var1) is
- record
- case Kind is
- when Var1 => Var1 : String (1 .. 1);
- when Var2 => Var2 : String (1 .. 2);
- ...
- when Var15 => Var15 : String (1 .. 15);
- end case;
- end record;
-
- which also requires a case statement at each reference to the
- component of an object of type Dyn_String (so that the correct
- component name can be referenced). The author's limit of 15 on the
- length of "dynamic strings" is probably due to the pain threshold of
- extending the above lists beyond 15 elements. Though I don't know for
- sure, the author's original problem in the DEC system may, simply,
- have been due to the use of Natural as the subtype of the
- discriminant. I suspect that the DEC system, in elaborating an object
- of type Dyn_String (declared according to the original formulation),
- reserves storage for an object of the maximum size, which would occur
- when the discriminant acquires the value Natural'Last (a pretty big
- number). The integer overflow might have occurred during some kind of
- address computation. (I believe there are implementation techniques
- that avoid reserving the maximum storage that might be needed for each
- object of the type, by deferring storage allocation and reclamation until
- assignment.) In any case, what the author should have done, I
- believe, is decide on a sensible maximum length for dynamic strings,
- whether 15 or 80 or 2000, and proceed as follows:
-
- Max_String_Length : constant := 80;
- subtype String_Length is Natural range 1 .. Max_String_Length;
- type Dyn_String (Length : String_Length := 80) is
- record
- Dyn_Str : String (1 .. Length);
- end record;
-
- The author did not indicate whether this had been tried. I am
- inclined to believe it would have been successful. I can tell you
- that I have tried it in the Verdix system, and it works as I expected
- it to. (I recall some discussion of this common programming "error"
- on the net within the past year.) With such a change, the source code
- of the submission becomes less cumbersome, and the conflict of
- names problem I discussed above almost disappears, but not quite
- (variant parts are still needed to discriminate between the case of an
- integer component and that of a string component of some record type).
-
- Ken Dritz (Dritz @ ANL-MCS.ARPA)
-