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,e8550e5b10c2c0 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-28 14:16:52 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newspeer.radix.net!uunet!ash.uu.net!xyzzy!nntp From: John Harbaugh Subject: Re: Variant Record Component X-Nntp-Posting-Host: e245845.nw.nos.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3E5FDD98.388AC976@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: <3E5F8B38.EE7AE76F@boeing.com> Mime-Version: 1.0 Date: Fri, 28 Feb 2003 22:07:20 GMT X-Mailer: Mozilla 4.73 [en]C-CCK-MCD Boeing Kit (Windows NT 5.0; U) Xref: archiver1.google.com comp.lang.ada:34743 Date: 2003-02-28T22:07:20+00:00 List-Id: Freezing rules are defined in ARM 13.14. In short, freezing is the point either in compilation or elaboration at which the memory structure of an entity must be fixed. Because of these rules, the following representation clause is illegal: type Byte is mod 2**8; subtype Nibble is Byte range 0..2*4; for Nibble'Size use 4; In the case of the variant record in question, the record type does not have a defaulted discriminant (a definite type). When a record object is declared, a discriminant value must be supplied (a constrained object), at which point the structure of the object is "frozen" at compile time. If, on the other hand, the record type had a default expression for the discriminant (an indefinite type) and the object declaration did not override the default (an unconstrained object), then freezing would also occur at runtime, because the structure could change (through whole-value assignment). Variant records a are a little subtle in this regard. You are correct, the field "b" may not exist, in which case a Constraint_Error is raised when the nonexistent field is referenced. So, I guess it really is unnecessary to have a language feature to test the structure. One can simply test the discriminant. In this particular case, I would still advocate for re-factoring the routine because it is obscenely big, but that's another issue. Cheers, - John > Constraint_Error because of errors in the data (a field is out of range, > for instance), or because the program referenced msg.b when the > discriminant/case statement said there was no field "b"? In the latter > case, it sounds like the symptom is the attempt to reference msg.b, but the > problem is erroneously thinking this message is of the subtype with a "b".