comp.lang.ada
 help / color / mirror / Atom feed
* ObjectAda vs Gnat -- bugs
@ 1997-05-15  0:00 granger
  1997-05-15  0:00 ` Stephen Leake
                   ` (4 more replies)
  0 siblings, 5 replies; 39+ messages in thread
From: granger @ 1997-05-15  0:00 UTC (permalink / raw)



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 ?

If gnat is correct ( probably gnat!!!), the internal package RGB_Value does
 not have any influence, how can I have the enumeration values Gray* and
 Grey* of the same type or subtype with the same internal value ?

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---------------
end rgbcolor;








^ permalink raw reply	[flat|nested] 39+ messages in thread
* Re: ObjectAda vs Gnat -- bugs
@ 1997-05-16  0:00 Keith Thompson
  1997-05-16  0:00 ` Robert A Duff
  0 siblings, 1 reply; 39+ messages in thread
From: Keith Thompson @ 1997-05-16  0:00 UTC (permalink / raw)



louis.granger@MAIL.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 ?
>  
> If gnat is correct ( probably gnat!!!), the internal package RGB_Value does
>  not have any influence, how can I have the enumeration values Gray* and
>  Grey* of the same type or subtype with the same internal value ?
>  
> 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---------------
> end rgbcolor;

Actually, I believe ObjectAda is correct on this one -- but the reasons
are rather obscure.  By the way, the contents of the package RGB_Value
are irrelevant here.

Here's a simpler example:

    package RGBColor is
        type Color_Type is ( Gray0, Gray1 );
        Grey0 : Color_Type renames Gray0;
        Grey1 : Color_Type renames Gray1;
    end RGBColor;

By RM95-8.5.1(4), the renamed entity in an object renaming must be an object.

By RM95-3.5.1(6), an enumeration literal specification declares a
parameterless function, so an occurrence of an enumeration literal
in an expression is a function call.  This rule may seem strange;
it's defined that way so that enumeration literals can be overloaded
in the same manner as functions.  In practice, you can be sure that
enumeration literals will not be implemented as actual function calls.

By RM95-6.4(12) and 6.5(21), a function call denotes a (constant)
object.  (This rule is new to Ada 95.)

So, it is legal in Ada 95 (but illegal in Ada 83) to use an object
renaming declaration to rename an enumeration literal.

However, the more traditional way to rename an enumeration literal
is as a function:

    package RGBColor is
	type Color_Type is ( Gray0, Gray1 );
	function Grey0 return Color_Type renames Gray0;
	function Grey1 return Color_Type renames Gray1;
    end RGBColor;

Or, if you aren't worried about overloading, just declare some constants:

    package RGBColor is
	type Color_Type is ( Gray0, Gray1 );
	Grey0 : constant Color_Type := Gray0;
	Grey1 : constant Color_Type := Gray1;
    end RGBColor;

-- 
Keith Thompson (The_Other_Keith) kst@sd.aonix.com <http://www.aonix.com> <*>
TeleSo^H^H^H^H^H^H Alsy^H^H^H^H Thomson Softw^H^H^H^H^H^H^H^H^H^H^H^H^H Aonix
5040 Shoreham Place, San Diego, CA, USA, 92122-5989
"Zathras warn Zathras, but Zathras never listen to Zathras." -- Zathras




^ permalink raw reply	[flat|nested] 39+ messages in thread
* Re: ObjectAda vs Gnat -- bugs
@ 1997-05-19  0:00 tmoran
  1997-05-19  0:00 ` Jon S Anthony
  0 siblings, 1 reply; 39+ messages in thread
From: tmoran @ 1997-05-19  0:00 UTC (permalink / raw)



So if I wanted to make some reusable object with the characteristics:
  constant once created
  creation requires info not conveniently done with discriminants
  limited
one approach would be to make the type T limited and tell users to declare
  X : T renames Create(...);
Right?




^ permalink raw reply	[flat|nested] 39+ messages in thread
* Re: ObjectAda vs Gnat -- bugs
@ 1997-05-30  0:00 John Walker
  0 siblings, 0 replies; 39+ messages in thread
From: John Walker @ 1997-05-30  0:00 UTC (permalink / raw)



This may already have been answered, but ...

On Wed, 28 May 1997 13:03:31 -0400
  Stephen Leake <Stephen.Leake@GSFC.NASA.GOV> asked:

>Thanks, but where, exactly, do I find the "AARM"? I assume this is the
>"Annotated Ada Reference Manual", but I cannot find it at AdaHome or
>AdaIC. I assume this is NOT the Rationale.

go to http://sw-eng.falls-church.va.us/AdaIC/standards/

and there's a link to a choice of .txt, .ps, and .zip files:

http://sw-eng.falls-church.va.us/AdaIC/standards/95lrm/LRMascii/
http://sw-eng.falls-church.va.us/AdaIC/standards/95lrm/LRMps/
http://sw-eng.falls-church.va.us/AdaIC/standards/95lrm/LRMzip/

take care,

John
         ---------------------------------------------------
           John Walker, walkerj@sw-eng.falls-church.va.us
              ---Assembler is a high-level language.---
 .GET DSCLAIMR.STD   ; & consider the effect of the insertion point
         ---------------------------------------------------




^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~1997-05-31  0:00 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-05-15  0:00 ObjectAda vs Gnat -- bugs granger
1997-05-15  0:00 ` Stephen Leake
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   ` Jon S Anthony
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 ` Samuel A. Mize
1997-05-15  0:00 ` Samuel A. Mize
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         ` Robert A Duff
1997-05-30  0:00           ` Matthew Heaney
1997-05-31  0:00             ` Robert A Duff
1997-05-30  0:00         ` Samuel Mize
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

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