From: collberg@dna.lth.se (Christian S. Collberg)
Subject: Readonly variables in Ada?
Date: 5 Jun 90 08:56:54 GMT [thread overview]
Message-ID: <1990Jun5.085654.920@lth.se> (raw)
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
appropriate sections in the LRM, and I don't have a compiler at hand
to try it out, so maybe someone out there could enlighten me...
Maybe something along these lines might work (excuse the syntax, I'm not an
Ada programmer):
---------------------------
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;
---------------------------
---------------------------
with P;
declare
x : BOOLEAN;
begin
P.v := false; -- Obviously illegal, as it should be
-- for a read only variable.
if P.v = true then -- Doesn't seem like this would be
... -- legal since equality is undefined
-- for limited private types.
if P.v then -- legal ?
...
if P.v OR x then -- legal ?
...
end;
---------------------------
Would one, in order to achieve the desired effect, have to provide,
in the interface of P, overloaded operators for the type T (=, OR, AND,
etc for this example)?
Thanks in advance for any help you may offer in clearing this up for me.
Chris Collberg
collberg@dna.lth.se
next reply other threads:[~1990-06-05 8:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1990-06-05 8:56 Christian S. Collberg [this message]
1990-06-05 13:21 ` Readonly variables in Ada? Pat Rogers
1990-06-05 16:22 ` David Collard
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