[comp.lang.ada] Formal out parameters

km38#@andrew.cmu.edu.UUCP (02/25/87)

Another problem...

with the following declaration,

type RESOURCE_REC;

type RESOURCE is
  access RESOURCE_REC;

type RESOURCE_REC is
  record
    RESOURCE_NAME : FOO.NAME;
    ...
  end;

procedure CREATE (NEW_RESOURCE : out RESOURCE;
                  RESOURCE_NAME : in FOO.NAME) is
begin
  NEW_RESOURCE := new RESOURCE_REC;
  NEW_RESOURCE.RESOURCE_NAME := RESOURCE_NAME;
end CREATE;

I get the following error (for the second assignment):

  106           NEW_RESOURCE.RESOURCE_NAME := RESOURCE_NAME;
................1
%ADAC-E-READ, (1) Reading from subprogram 'out' formal NEW_RESOURCE at line
92 
        is not allowed

Does this mean that my parameter declaration only allows me to assign a value
to the pointer, not to the record pointed to? It seems to me that this error
is not justified, as I am not reading anything from the NEW_RESOURCE
parameter, but merely initializing (writing to) part of it.

Also, with another compiler validated with ACVC 1.5, there is no error.

Thanks,

--Magnus
Arpa: magnus@andrew.cmu.edu
UUCP: seismo!andrew.cmu.edu!magnus