comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <Stephen.Leake@gsfc.nasa.gov>
Subject: Re: ObjectAda vs Gnat -- bugs
Date: 1997/05/15
Date: 1997-05-15T00:00:00+00:00	[thread overview]
Message-ID: <337B65FC.98D@gsfc.nasa.gov> (raw)
In-Reply-To: 5lf6ka$nbg@service.polymtl.ca


granger wrote:
> 
> Here is a shortened version of a package that I wrote.
> 
> It compiles without any error with ObjectAda.
> With gnat3.09, I have the following errors:
> 
> rgbcolor.ads:18:41: expect object name in renaming
> rgbcolor.ads:19:49: expect object name in renaming
> 
> Which of the compilers is correct ?

gnat; see below

> 
> If gnat is correct ( probably gnat!!!), the internal package RGB_Value does
>  not have any influence, 

Since you did not do "use RGB_Value" nor "RGB_Value.", this is true;
RGB_Value has no influence.

>          how can I have the enumeration values Gray* and
>  Grey* of the same type or subtype with the same internal value ?

you can't have two distinct enumeration values of the same type with the
same internal value, but you can get the effect of renaming; see below.

> 
> Thank in advance for any suggestion.
> 
> package rgbcolor is
>         package RGB_Value is
>                 type Color3  is
>                 record
>                         red, green, blue : Float;
>                 end record;
>                 Gray0   : constant Color3 := ( 0.000, 0.000, 0.000 );
>                 Grey0   : Color3 renames Gray0;
>                 Gray1   : constant Color3 := ( 0.012, 0.012, 0.012 );
>                 Grey1   : Color3 renames Gray1;
>         end RGB_Value;
> 
>         type Color_Type is ( Gray0, Gray1 );
> 
>         subtype Grey_Color_Type is Color_Type range Gray0 .. Gray1;
> 
>         Grey0   : Color_Type renames    Gray0;  -- line in error---------------
>         Grey1   : Color_Type renames    Gray1;  -- line in error---------------

replace the error lines with:

        function Grey0 return Color_Type renames Gray0;
        function Grey1 return Color_Type renames Gray1;

> end rgbcolor;

An enumeration literal acts like a function with no parameters, so you
can rename it as a function. Your original renaming was trying to
declare an object, which GNAT correctly forbids; submit an error report
to Aonix!

However, if you are expecting rbbcolor.Grey0 to return the same value as
rgbcolor.RBG_Value.Grey0, you are confused; one is a scalar enumeration
type, the other is a record type with three components. You could add
the declarations:

        Grey0 : RGB_Value.Color3 renames RGB_Value.Gray0;
        Grey1 : RGB_Value.Color3 renames RGB_Value.Gray1;

But I'm not clear what you are after.

-- 
- Stephe




  parent reply	other threads:[~1997-05-15  0:00 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-05-15  0:00 ObjectAda vs Gnat -- bugs granger
1997-05-15  0:00 ` Samuel A. Mize
1997-05-15  0:00 ` Samuel A. Mize
1997-05-15  0:00 ` Robert Dewar
1997-05-16  0:00   ` David L Brown
1997-05-16  0:00     ` Robert Dewar
1997-05-17  0:00       ` Tom Moran
1997-05-18  0:00         ` Jon S Anthony
1997-05-19  0:00         ` Tucker Taft
1997-05-19  0:00       ` Tom Moran
1997-05-15  0:00 ` Stephen Leake [this message]
1997-05-16  0:00   ` Jon S Anthony
1997-05-16  0:00   ` Tucker Taft
1997-05-16  0:00     ` Jon S Anthony
1997-05-16  0:00       ` Robert Dewar
1997-05-17  0:00         ` Jon S Anthony
1997-05-16  0:00       ` Tom Moran
1997-05-16  0:00 ` Robert A Duff
1997-05-16  0:00   ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1997-05-16  0:00 Keith Thompson
1997-05-16  0:00 ` Robert A Duff
1997-05-16  0:00   ` Robert Dewar
1997-05-18  0:00     ` Nick Roberts
1997-05-19  0:00       ` Robert Dewar
1997-05-20  0:00         ` Nick Roberts
1997-05-21  0:00           ` Robert Dewar
1997-05-23  0:00   ` Stephen Leake
1997-05-24  0:00     ` Robert A Duff
1997-05-28  0:00       ` Stephen Leake
1997-05-30  0:00         ` Samuel Mize
1997-05-30  0:00         ` Robert A Duff
1997-05-30  0:00           ` Matthew Heaney
1997-05-31  0:00             ` Robert A Duff
1997-05-19  0:00 tmoran
1997-05-19  0:00 ` Jon S Anthony
1997-05-20  0:00   ` Jeff Carter
1997-05-20  0:00   ` Nick Roberts
1997-05-25  0:00     ` Tom Moran
1997-05-30  0:00 John Walker
replies disabled

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