[comp.lang.ada] Question about Ada renaming...

stluka@software.org (Fred Stluka) (03/19/91)

Here is a question for the Ada gurus.

The Apollo (Verdix) Ada compiler accepts it;
the VAX Ada compiler reports errors at compile time.

Which is correct?

-----------------------------------

package aaa is 
    type int is new integer;
end;

with aaa;
package bbb is
    procedure proc (param : in out aaa.int);
end bbb;

with aaa;
with bbb;
procedure ccc is
    package a renames aaa;
    local_int : integer;
begin
    bbb.proc (aaa.int (local_int));   -- Works fine.
    bbb.proc (a.int (local_int));     -- Doesn't compile on VAX.
end ccc;

-----------------------------------

VAX Ada error messages:

Line  17:           bbb.proc (a.int (local_int));     -- Doesn't compile on VAX.
%ADAC-E-CONFDIFFNAME, Name a is not the same as aaa in bbb at line 7 [LRM 6.3.1]

Line  17:           bbb.proc (a.int (local_int));     -- Doesn't compile on VAX.
%ADAC-I-CONFWITHTYPEMAR, Error detected during conformance check with type mark 
        of subprogram 'in out' formal param in bbb at line 7

-----------------------------------

The referenced Ada RM section seems relevant.  To paraphrase:

     6.3.1(6)   Such conformance is required for type conversions
                used as actual parameters (see 6.4.1).

     6.4.1(3)   For a type conversion used as an actual parameter 
                of mode in out the type mark must conform (see 6.3.1)
                to the type mark of the formal parameter.

The heart of my question is:

     Should this usage (referring to the type mark via a renaming
     declaration) be considered a case of nonconformance?

If so, is there a way around this problem, other than the "Works fine"
line above, or a use clause?  This is abstracted out from a much more
complicated example in a large system where we use a standard set of
renames across the project.

--Fred
-- 

Fred Stluka                              Internet: stluka@software.org
Software Productivity Consortium         UUNET:    ...!uunet!software!stluka
2214 Rock Hill Rd, Herndon VA 22070 USA 

NCOHEN@IBM.COM ("Norman H. Cohen") (03/20/91)

Fred Stluka asked whether the type marks A.INT and AAA.INT, where A is a
renaming of package AAA, should be considered to conform.  According to
Ada 83 rules, they should not.  RM paragraphs 6.3.1(5,6) state:

    5  Two subprogram specifications are said to _conform_ if,
       apart from comments and the above allowed variations, both
       specifications are formed by the same sequence of lexical
       elements, and corresponding lexical elements are given the
       same meaning by the visibility and overloading rules.

    6  Conformance is likewise defined for formal parts, discriminant
       parts, and type marks (for deferred constants and for actual
       parameters that have the form of a type conversion (see 6.4.1)).

Paragraph 6 states that conformance of type marks is given by the same
rules as conformance of subprogram specifications, namely those in
paragraph 5.  Paragraph 5 requires identical sequences of lexical
elements (which "A.INT" and "AAA.INT" clearly are not) except for the
"above allowed variations" described in paragraphs 2-4.  These variations
allow numeric literals to conform to differently written but equivalent
numeric literals (e.g. 40960, 40_960, 4096E1, 16#A000#, 16#A#E3),
expanded names to conform to corresponding simple names (e.g. INT and
A.INT), and operator symbols to conform to differently capitalized
operator symbols (e.g. "AND", "And", and "and").  They do not allow a
name to conform to another name, declared by a renaming declaration to
denote the same entity.

Conformance is not transitive:  Though A.INT conforms to INT and INT
conforms to AAA.INT, A.INT does not conform to AAA.INT.

stluka@software.org (Fred Stluka) (03/22/91)

In article <9103201431.AA27295@ajpo.sei.cmu.edu> NCOHEN@IBM.COM ("Norman H. Cohen") writes:
> Fred Stluka asked whether the type marks A.INT and AAA.INT, where A is a
> renaming of package AAA, should be considered to conform.  According to
> Ada 83 rules, they should not.
> ...
> Conformance is not transitive:  Though A.INT conforms to INT and INT
> conforms to AAA.INT, A.INT does not conform to AAA.INT.

Thanks for the definitive answer, Norm.

Another question:  Why is it defined this way?  For ease of 
implementation only?  Or is there another reason?  I couldn't
find the answer in the "Rationale for the Design of the Ada 
Programming Language".

Finally:  What are the dates of the most current versions of
the rationale document (my copy is copyrighted 1986), and the 
Ada "Implementer's Guide" (various pages of my copy are marked:
     "DRAFT Version G1; 82-09-29",
     "DRAFT Version G2; 84-12-26", 
     "DRAFT Version G1; 85-05-01",
etc)?  And where can I get current versions?

Thanks,
--Fred
-- 

Fred Stluka                              Internet: stluka@software.org
Software Productivity Consortium         UUNET:    ...!uunet!software!stluka
2214 Rock Hill Rd, Herndon VA 22070 USA