From: John Harbaugh <john.s.harbaugh2@boeing.com>
Subject: Re: Variant Record Component
Date: Fri, 28 Feb 2003 16:15:52 GMT
Date: 2003-02-28T16:15:52+00:00 [thread overview]
Message-ID: <3E5F8B38.EE7AE76F@boeing.com> (raw)
In-Reply-To: mailman.0.1046292617.1343.comp.lang.ada@ada.eu.org
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" <john.s.harbaugh2@boeing.com>
> Newsgroups: comp.lang.ada
> To: <comp.lang.ada@ada.eu.org>
> 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
> >
next prev parent reply other threads:[~2003-02-28 16:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-26 18:00 Variant Record Component John Harbaugh
2003-02-26 19:08 ` Stephen Leake
2003-02-27 8:17 ` Anders Wirzenius
2003-02-27 8:46 ` John McCabe
2003-02-27 17:26 ` phone number database Stephen Leake
2003-02-27 18:09 ` tmoran
2003-02-28 0:07 ` Matthew Heaney
2003-02-28 6:46 ` Hijacking threads (was phone number database (was Variant Record Component)) Anders Wirzenius
2003-02-26 20:50 ` Variant Record Component David C. Hoos
2003-02-28 16:15 ` John Harbaugh [this message]
2003-02-28 18:18 ` tmoran
2003-02-28 22:07 ` John Harbaugh
2003-02-28 20:51 ` Randy Brukardt
2003-03-01 2:34 ` Jeffrey Carter
2003-03-03 9:24 ` John McCabe
2003-02-26 21:37 ` tmoran
-- strict thread matches above, loose matches on Subject: below --
2003-02-28 19:40 David C. Hoos
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox