[net.lang.ada] Please Test This

rosen@gypsy.UUCP (10/03/85)

Can someone run this small program through their Ada compiler and let me
know what it has to say.  I've already run it though the Verdix compiler and
the Ada/ED compiler both for Unix 4.2 on a Vax.  If you have a different
compiler, then I'd like to know what it has to say.

The error concerns the importation of the equality operator for objects that
are of an access type and are declared in a different package.  The Verdix
compiler says that if I do not issue a "use" clause for the imported package
(the one with the access type definitions), then I must qualify the "="
operator since it is not directly visible.  The Ada/ED compiler doesn't
require this.  I believe the Verdix compiler is right since it is taking the
LRM literally, but I would like to know what other compilers say.

Here's the program:

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

package IMPORT_ACCESS_TYPE is

  type POINTER is access INTEGER;
  --
  -- Declaration of a public access type.
  --
  
end IMPORT_ACCESS_TYPE;

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

with IMPORT_ACCESS_TYPE;  -- Notice the the lack of a 'use' clause
			  -- which is very important in this example

procedure MAIN is
  X,Y: IMPORT_ACCESS_TYPE.POINTER;
begin

  --
  -- The compiler will/should complain about the test for equality in the
  -- following statement since the "=" operator is not directly visible.
  -- 
  if (X = null) then
    Y := X;
  end if;

  --
  -- The compiler should not complain about the test for equality in the
  -- following statement.  This form is required if there is no "use" clause
  -- for the package which declares the access types.
  --
  if (IMPORT_ACCESS_TYPE."=" (X, null)) then
    Y := X;
  end if;

end MAIN;

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

------------
Steve Rosen
Siemens Research and Technology Laboratories
Princeton, NJ

USENET: {ihnp4|princeton|adrvax}!siemens!gypsy!rosen
ARPA:   siemens!gypsy!rosen@TOPAZ

stt@ada-uts.UUCP (10/07/85)

All of the Intermetrics Ada compilers agree with the Verdix requirement.
Access types are not special in any way w.r.t. equality.
You must "use" the package, or locally rename the "=" operator,
or qualify it as you have done in the second usage.