comp.lang.ada
 help / color / mirror / Atom feed
* Readonly variables in Ada?
@ 1990-06-05  8:56 Christian S. Collberg
  1990-06-05 13:21 ` Pat Rogers
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christian S. Collberg @ 1990-06-05  8:56 UTC (permalink / 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1990-06-05 18:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
1990-06-05 18:01 ` Robert I. Eachus

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