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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2def9aa85afa5d22 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-08 07:13:08 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.mailgate.org!zur.uu.net!ash.uu.net!xyzzy!nntp From: Rex Reges Subject: Re: Joint Strike Fighter X-Nntp-Posting-Host: e919331.sea.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3BEA9CED.8C6BF839@reges.org> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: <3BDCE159.39F6D422@adaworks.com> <11bf7180.0110290311.4d8d6f04@posting.google.com> <3BDF9C6A.C25520C5@adaworks.com> <3BE023AB.8F235EF5@sparc01.ftw.rsc.raytheon.com> <9rp8mo$6d8$1@nh.pace.co.uk> <9rrmvl$98d$1@nh.pace.co.uk> <3BE4221B.34589071@adaworks.com> <3BE43CDC.F6B1EE30@acm.org> <3BE813E4.C4797DDE@reges.org> <3BE853FD.513040F@reges.org> Larry Kilgallen wrote: > > In article <3BE853FD.513040F@reges.org>, Rex Reges writes: > > > Upon this conclusion, I can now make sense of the Ada coding > > practices I've seen: > > > - Assigning all of the components of a record one at > > a time instead of using an aggregate assignment. > > It must be done separately if your design involves making > two successive assignments to the same component and none > to some other component. > When reading code where every assignment is done on primitive components throughout, I find this reminiscent of writing a C program since C doesn't have an assignment operator for things like structures and arrays. Tedious, eh? You can use memmov, of course, but that has all sorts of dangers of its own. Generally, it is a good idea to make an aggregate assignment for a record, since any change in the record type will then cause a compiler error if some part of the code is not updated. I'm sure you are not suggesting that we eliminate this guideline, but rather allow exceptions. I've ran into a few myself: - Some structures are too big to even initialize with an aggregate assignment (a 128kB memory mapped device control areas, for example). - When frequently appending to the same variable structure by modifying the variant part is inefficient; it's better to expand the variable to the max expected size once, filling it with dummy data, and then overwrite the individual subcomponents one at a time. - If there is the possibility that a subcomponent is out of range, then you need individual assignments of the subcomponents to perform a constraint check. The constraint check is only required for the assignment operator and the constraint checks for a record assignment are only to verify the variant parts are in range. I've seen this happen when an ASCII string (Ada83) was read in with 8-bit characters in it (someone used the compose key to create a degree symbol). Another time, a floating point conversion routine didn't catch that the exponent was greater than the 255 max value since I set the entire floating point structure in a single aggregate assignment. I certainly can't disagree with you over this point! Rex Reges