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=1.2 required=5.0 tests=BAYES_20,GAPPY_SUBJECT, INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!att!cbnewsl!willett From: willett@cbnewsl.att.com (david.c.willett) Newsgroups: comp.lang.ada Subject: Re: Types defining h/w r/o or w/o registers Summary: Limited private types (read only) Message-ID: <1991May31.170353.21919@cbnewsl.att.com> Date: 31 May 91 17:03:53 GMT References: <3949@titan.tsd.arlut.utexas.edu> Distribution: usa Organization: AT&T Bell Laboratories List-Id: In article <3949@titan.tsd.arlut.utexas.edu>, gardner@titan.tsd.arlut.utexas.edu (Don Gardner) writes: > Is there some way to define a type such that all variables of that > type can be only read or only written? For instance, I have a type that > defines the status register of some peripheral which can only be > read. It would be best if the compiler could flag any assignments > to variables of such a type as errors. > > Is there some other means for commonly handling this problem? The > compiler being used is VADSWorks, if an implementation-defined solution > is required. Don, The Ada LRM defines a "limited private" type as being one for which the assignment operators are not valid outside the package in which the type is declared (see Booch, "Programming in Ada" pg. 125). I think that will take care of the read only case. Only suggestion I have on write only is to hide the write operation in a package and provide no corresponding read function. Good Luck, Dave Willett