Thread View: net.lang.ada
1 messages
1 total messages
Started by Geoff Mendal
Fri, 03 Oct 1986 11:27
Re: Quite Limited!
Author: Geoff Mendal
Date: Fri, 03 Oct 1986 11:27
Date: Fri, 03 Oct 1986 11:27
29 lines
1630 bytes
1630 bytes
Concerning mode 'out' on limited formals not defined in
the package spec where the limited type is defined...
The reason for this restriction has to do with data integrity.
Consider the following (semantically invalid) compilation unit:
with Text_Io;
procedure Destroy_File (File : out Text_Io.File_Type) is
begin
null;
end Destroy_File;
If pass by reference is used, no problem. But if pass by copy is
used, watch out: the copy back rule will result in a junk value being
assigned to the actual parameter. The restriction is meant to
preserve data privacy, and thwart attempts to destroy "limited" values
without the defining package knowing about it.
Note that for mode 'out' parameter associations, copy-in is not required
except for some esoteric cases (see references below). This is an
important difference between mode 'out' and 'in out'. In any case,
the fix to your program is simple: use mode 'in out' instead of 'out'.
References:
LRM: 6.2(6 .. 7); 7.4.4(4)
Barnes, "Programming in Ada": pp. 125, 132, 340
gom
-------
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads