From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d0452dbe16ac0df4 X-Google-Attributes: gid103376,public From: "Samuel A. Mize" Subject: Re: ObjectAda vs Gnat -- bugs Date: 1997/05/15 Message-ID: <337B4CF4.41C6@magellan.bgm.link.com>#1/1 X-Deja-AN: 241791479 References: <5lf6ka$nbg@service.polymtl.ca> Organization: PSI Public Usenet Link Newsgroups: comp.lang.ada Date: 1997-05-15T00:00:00+00:00 List-Id: 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!!!), Good guess! >the internal package RGB_Value does > not have any influence, Also correct. >how can I have the enumeration values Gray* and > Grey* of the same type or subtype with the same internal value ? You can't, but you can come close. An enumeration literal is a function that returns a value of the enumeration type. For instance, this works: function Fred return character renames 'A'; So, you CAN define your own functions that rename enumeration literals. For instance, this program compiles and works with GNAT: with Text_Io; procedure Fred is type Color_Type is (Gray0); function Grey0 return Color_Type renames Gray0; begin Text_Io.Put_Line (Color_Type'Image ( Grey0 )); -- outputs GRAY0, not GREY0 end fred; Whether or not this is a good idea I leave to the engineer on the scene. Sam Mize > 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; -- Samuel Mize (817) 619-8622 "Team Ada" -- Hughes Training Inc. PO Box 6171 m/s 400, Arlington TX 76005