comp.lang.ada
 help / color / mirror / Atom feed
From: deadlyhead <deadlyhead@gmail.com>
Subject: Re: Determining value of record discriminant
Date: Mon, 19 Jul 2010 17:33:49 -0700 (PDT)
Date: 2010-07-19T17:33:49-07:00	[thread overview]
Message-ID: <a9204c43-8ee9-47a5-a0eb-fe348126d967@z15g2000prn.googlegroups.com> (raw)
In-Reply-To: i22quk$qs9$1@tornado.tornevall.net

On Jul 19, 5:26 pm, "Jeffrey R. Carter"
<spam.jrcarter....@spam.acm.org> wrote:
> On 07/19/2010 03:36 PM, deadlyhead wrote:
>
>
>
>
>
> > --  code begins
> > type Discrim_Val is (Int, Str);
>
> > type Discrim_Rec (D : Discrim_Val) is record
> >     case D is
> >        when Int =>
> >           Val_Int : Integer := 1_000_000;
> >        when Str =>
> >           Val_Str : String (1 .. 11) := "One million";
> >     end case;
> > end record;
> > --  code ends
>
> > Is there any way to determine what the discriminant value was on a
> > type later on, i.e. with a dynamically allocated Discrim_Rec object
> > created with user input for D?  A haven't found anything looking
> > through the RM about attributes or anything providing this
> > functionality.
>
> V : Discrim_Rec := Some_Func;
>
> case V.D is
> when Int =>
>     ...
> when Str =>
>     ...
> end case;
>
> The discriminant is a field just like any other.
>
> --
> Jeff Carter
> "How'd you like to hide the egg and gurgitate
> a few saucers of mocha java?"
> Never Give a Sucker an Even Break
> 101

Thank you!  I really don't know how I missed that.



  reply	other threads:[~2010-07-20  0:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-19 22:36 Determining value of record discriminant deadlyhead
2010-07-20  0:26 ` Jeffrey R. Carter
2010-07-20  0:33   ` deadlyhead [this message]
2010-07-20  8:53   ` Maciej Sobczak
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox