comp.lang.ada
 help / color / mirror / Atom feed
From: vladimir@speedy.intrepid.com (Vladimir Vukicevic)
Subject: Re: C++ to Ada95, help please
Date: 22 Mar 1995 05:07:58 GMT
Date: 1995-03-22T05:07:58+00:00	[thread overview]
Message-ID: <VLADIMIR.95Mar21210758@speedy.intrepid.com> (raw)
In-Reply-To: kevq@banana.demon.co.uk's message of Tue, 21 Mar 1995 23:27:35 GMT

In article <3kjd2m$d3t@jerry.rb.icl.co.uk>,
          skj@rb.icl.co.uk (Simon Johnston) wrote:

I think you want something like:

package Foo is
    type A_Type is (FOO, BAR);
    for A_Type'Size use 8;	--  Should probably be Integer'Size or whatever
    for A_Type use
        (FOO => 1, BAR => 2);

    type Blah (disc : A_Type) is
        record
            case disc is
                when FOO =>
                    one : Integer;
                when BAR =>
                    two : Integer;
            end case;
        end record;

    for Blah use
        record
            disc at 0 range 0 .. (A_Type'Size-1);
            one at 1 range 0 .. (Integer'Size-1);
            two at 1 range 0 .. (Integer'Size-1);
        end record;
end Foo;

With the right types and sizes, of course, but this should work. Note that
you have to speicifically decide which of the variables you want to be
your discriminant; in your example, item1 or item2... if these can only
legally hold values of constants, you should consider creating an
enumerated type with a representation clause, as above.

	- Vladimir



  reply	other threads:[~1995-03-22  5:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-20  8:06 C++ to Ada95, help please Simon Johnston
1995-03-21 23:27 ` Kevin F. Quinn
1995-03-22  5:07   ` Vladimir Vukicevic [this message]
1995-03-22  1:22 ` Tucker Taft
1995-03-22 11:38   ` Robb Nebbe
1995-03-23 12:28   ` Mike Meier
1995-03-23 18:31     ` Tucker Taft
1995-03-24 21:24     ` Robert Dewar
1995-03-27 14:58       ` Norman H. Cohen
1995-03-23 13:30   ` Robert Dewar
1995-03-23 18:01 ` Stephen A. Leake
1995-03-24  9:07   ` Vladimir Vukicevic
1995-03-25 10:02     ` Keith Thompson
  -- strict thread matches above, loose matches on Subject: below --
1995-03-08  7:54 Simon Johnston
1995-03-08 13:56 ` Robert A Duff
1995-03-09 21:23 ` Tucker Taft
replies disabled

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