From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!lth.se!newsuser From: collberg@dna.lth.se (Christian S. Collberg) Newsgroups: comp.lang.ada Subject: Readonly variables in Ada? Message-ID: <1990Jun5.085654.920@lth.se> Date: 5 Jun 90 08:56:54 GMT Sender: newsuser@lth.se (LTH network news server) Reply-To: collberg@DNA.LTH.Se (Christian S. Collberg) Organization: Department of Computer Science, Lund University List-Id: 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