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=0.6 required=5.0 tests=BAYES_05,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ames!ll-xn!mit-eddie!uw-beaver!ssc-vax!shuksan!scott From: scott@shuksan.UUCP (Scott Moody) Newsgroups: comp.lang.ada Subject: Re: converted types as actual in out parameters Message-ID: <894@shuksan.UUCP> Date: 20 Sep 88 16:05:30 GMT References: <8809151803.AA17461@ajpo.sei.cmu.edu> Organization: The Boeing Co., BAC MMST, Seattle, WA List-Id: 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