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 08:36:41 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!uunet!dca.uu.net!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: <3E5F8B38.EE7AE76F@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: <3E5D00D6.F6A20AD2@boeing.com> Mime-Version: 1.0 Date: Fri, 28 Feb 2003 16:15:52 GMT X-Mailer: Mozilla 4.73 [en]C-CCK-MCD Boeing Kit (Windows NT 5.0; U) Xref: archiver1.google.com comp.lang.ada:34724 Date: 2003-02-28T16:15:52+00:00 List-Id: Here's the situation: I'm using a variant record to represent a Link 16 (JTIDS) J7.6 message for memory-mapped I/O. So a message comes in and, based on the message header, a particular structure is frozen. Now I pass the message object to a decode function that is looking for particular message fields. Well, surprise surprise, we occasionally raise Constraint_Error because the field in question is not present. Several options come to mind (in order of preferance): * Refactor the function and pass only the variant part instead of the entire message * Pass the discriminant value in to the function and have the function check it before referencing the variant part * Add a nested declare block in the function to try the variant part and handle the exception locally My question has more to do with understanding what language-level tools that are available. Ada is pretty slick at testing membership of a value within/without a subtype range. I was wondering if there was something analogous for variant records. I'm getting the impression that the answer is no. Yes? Thanks for your replies, - John "David C. Hoos" wrote: > > ----- Original Message ----- > From: "John Harbaugh" > Newsgroups: comp.lang.ada > To: > Sent: Wednesday, February 26, 2003 12:00 PM > Subject: Variant Record Component > > > Hi, all - > > > > Is there a way to determine if an object of some variant record type > > contains a specific variant component, other than a trying it and > > handling a possible constraint error? I looked for something like and > > "in" operator or suitable attribute, but found nothing. > Well, this sort of thing should not be necessary if the accesses to the > record components are done distinctly for different values of the > discriminant as part of a case statement; > > > > Thanks in advance, > > > > - John Harbaugh > > _______________________________________________ > > comp.lang.ada mailing list > > comp.lang.ada@ada.eu.org > > http://ada.eu.org/mailman/listinfo/comp.lang.ada > >