sboyd@meridian.COM (09/17/88)
Regarding your procedure -- procedure TEST is a : short_integer; procedure set_value( value : in out integer ) is begin value := 1; end set_value; begin set_value( integer(a) ); if a = 1 then put_line("This is a Vax-Ada compiler!"); else put_line("Is this a Verdix Ada compiler?"); end if; end TEST; -- Meridian's v2.2 AdaVantage also considers "a = 1" as a true predicate. Stowe Boyd Meridian Software Systems Director of Research and Development 23141 Verdugo Drive #105 sboyd%Meridian.COM@ICS.UCI.EDU Laguna Hills CA 92653 714/380-9800
GDAU100@BGUVM.BITNET ("Jonathan B. Owen") (09/17/88)
The following worked for Vax-Ada but not for Verdix Ada. Any thoughts? Is it a quirk of Vax-Ada to allow the following or a bug of Verdix which causes the return of erronious values? procedure TEST is a : short_integer; procedure set_value( value : in out integer ) is begin value := 1; end set_value; begin set_value( integer(a) ); if a = 1 then put_line("This is a Vax-Ada compiler!"); else put_line("Is this a Verdix Ada compiler?"); end if; end TEST; The Version of the Verdix Ada I tried was very old (ver. 2?). Maybe in newer version this is corrected. I noticed in this version that the "pack" pragma does not work! Each field of the packed record starts on a new boundry. Also, **** BUG IN VAX-ADA COMPILER ***, try converting a value of type real to short_integer. You will get during compilation "Compiler Internal Error"!. I solved the problem by an intermediate conversion to integer and only then to short_integer. I would appreciate any comments on the above. JB ______________________________________________________________________________ (--) /--) /-(\ Email: gdau100@bguvm (bitnet) \ / /--K | \|/\ /\/) /|-\ Snail: 55 Hovevei Zion _/_/o /L__)_/o \/\__/ \X/ \_/ | |_/ Tel-Aviv, 63346 ISRAEL (/ Jonathan B. Owen Voice: (03) 281-422 Point of view: A chicken is the means by which an egg reproduces an egg. ______________________________________________________________________________
scott@shuksan.UUCP (Scott Moody) (09/20/88)
In article <8809151803.AA17461@ajpo.sei.cmu.edu>, GDAU100@BGUVM.BITNET ("Jonathan B. Owen") writes: > The following worked for Vax-Ada but not for Verdix Ada. Any thoughts? > a: short_integer; pass integer(a) to an IN OUT routine ... I tried this program on my sun v5.41 verdix compiler, and the result was the same as you mentioned: 'Is this a Verdix Ada compiler?' I then started thinking and wondering if that really was valid Ada, so off to the LRM, page 6-8, sec 6.4.1, par 4: "The variable name given for an actual parameter of mode in out or out is evaluated before the call. If the actual parameter has the form of a type conversion (Yes in this case), then before the call, for a parameter of mode in out, the variable is CONVERTED to the specified type; after (normal) completion of the subprogram body, for a parameter of mode in out or out, the formal parameter is CONVERTED BACK to the type of the variable. (The type specified in the conversion must be that of the formal parameter.)" So the implementation should be something like: call_routine( integer(a)) ----- Translates to: declare tmp : integer; begin tmp := integer(a); call_routine(tmp); a := short_integer(tmp); begin ------ Interesting! Something that is not obvious since most programming languages would let the user convert to another type, but let them suffer when passing things by reference (more or less). Unfortunately this seems to be the erroneous implementation Verdix chose. -- scott @ Boeing Mountain Network
bs@augusta.UUCP (Burch Seymour) (09/23/88)
in article <8809151803.AA17461@ajpo.sei.cmu.edu>, GDAU100@BGUVM.BITNET ("Jonathan B. Owen") says: > > The following worked for Vax-Ada but not for Verdix Ada. Any thoughts? > Is it a quirk of Vax-Ada to allow the following or a bug of Verdix > which causes the return of erronious values? (text of test omitted) I ran this on the Gould compiler (Telesoft - Telegen 2) and it got the "Vax" result. I check the generated code and this is what happened: 1) The short integer is moved onto the stack - no check needed as a small is converted to a large. 2) The procedure is called. The result is on the stack at return as type integer. 3) The result is checked for range as a large is being converted to a smaller type. 4) The result is put away. I'm not a language lawyer, but this seems to be the way to do this. I'd guess the Verdix has a bug. -Burch Seymour - Gould CSD