comp.lang.ada
 help / color / mirror / Atom feed
From: Mendal@SIERRA.STANFORD.EDU (Geoff Mendal)
Subject: Re: Quite Limited!
Date: Fri, 3-Oct-86 07:27:44 EDT	[thread overview]
Date: Fri Oct  3 07:27:44 1986
Message-ID: <12243822862.9.MENDAL@Sierra.Stanford.EDU> (raw)

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
-------

             reply	other threads:[~1986-10-03 11:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1986-10-03 11:27 Geoff Mendal [this message]
  -- strict thread matches above, loose matches on Subject: below --
1986-09-30 19:00 Quite Limited! "ANCHOR::WILSON"
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox