From: collard@software.org (David Collard)
Subject: Re: Readonly variables in Ada?
Date: 5 Jun 90 16:22:52 GMT [thread overview]
Message-ID: <1261@software.software.org> (raw)
In-Reply-To: 1990Jun5.085654.920@lth.se
In article <1990Jun5.085654.920@lth.se> collberg@DNA.LTH.Se (Christian S. Collberg) writes:
> Is it possible to declare (the equivalent of) an exported readonly
> variable in Ada? I'm referring to something similar to the READ_ONLY
> attribute present in Mesa. I'm having a hard time reading the
> package P;
> type T is limited private;
> v : T; -- We want a client of P to be able to
> -- perform any operation on v, except
> -- assignment.
> private
> type T is BOOLEAN;
> end P;
I think, for a read only VARIABLE, there is an easier answer -- the type
can be visible, but declare the variable in the body of the package and
only provide an interface to read it.
package P is
function T return Boolean;
end P;
package body P is
Static_Package_Variable : Boolean;
function T return Boolean is
begin
return Static_Package_Variable;
end T;
end P;
with P;
procedure P_User is
begin
if P.T then --Legal
null;
end if;
P.Static_Package_Variable := False; -- Illegal because the variable is not
visible.
end P_User;
A
end P_User;
--
-----------------------------------------------------------------------
D. Thor Collard Internet: collard@software.org
Software Productivity Consortium UUNET: ...!uunet!software!collard
2214 Rock Hill Rd, Herndon VA 22070
next prev parent reply other threads:[~1990-06-05 16:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1990-06-05 8:56 Readonly variables in Ada? Christian S. Collberg
1990-06-05 13:21 ` Pat Rogers
1990-06-05 16:22 ` David Collard [this message]
1990-06-05 18:01 ` Robert I. Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox