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,GAPPY_SUBJECT, INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwvax!zazen!uakari.primate.wisc.edu!zaphod.mps.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: oops, wrong author Message-ID: <1991May31.171052.22235@cbnewsl.att.com> Date: 31 May 91 17:10:52 GMT References: <3949@titan.tsd.arlut.utexas.edu> <1991May31.170353.21919@cbnewsl.att.com> Distribution: usa Organization: AT&T Bell Laboratories List-Id: In article <1991May31.170353.21919@cbnewsl.att.com>, willett@cbnewsl.att.com (david.c.willett) writes: > 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 > Silly me, I listed the wrong author in the above post. As we all know, Grady Booch wrote "Software Engineering with Ada". It was J.G.P. Barnes who wrote "Programminng in Ada". My appologies to all concerned. Dave