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,b007c42c7898f4ef X-Google-Attributes: gid103376,public From: David Starner Subject: Re: First attribute on Enumerated types Date: 1999/02/23 Message-ID: <36D3678F.6C3CB1F6@aasaa.ofe.org>#1/1 X-Deja-AN: 447737658 Content-Transfer-Encoding: 7bit References: <001e01be5f9d$ebe4d7e0$5b824a0c@rogers> To: "James S. Rogers" X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: SLUG Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-02-23T00:00:00+00:00 List-Id: "James S. Rogers" wrote: > > David, > > I suspect that, in your case, Color is a variable, and not a subtype name. > The 'First attribute works for an enumeration type, not a variable of an > enumeration type. > > Jim Rogers > Colorado Springs, Colorado > > -----Original Message----- > From: David Starner > > >I'm trying to compile a program that refers to Color'First, and GNAT > >gives an error that > >tree.ads:12:91: prefix for "First" attribute must be array > >According to the Ada book at hand, First is a valid attribute for > >enumerated types. What am I doing wrong? How do I get the first item in > >an enumerated list? Since I quickly composed the first message, here's the actual code. Color is definitely a type. It should be enumerated - is there any way to tell the compiler that? In retrospect, that's probably my error. with Lists; generic type Node_type is private; type Color is private; package Tree is type Tree is limited private; type Node_Pointer is access Node_type; type TreePointer is access Tree; package Tree_List is new Lists(TreePointer, Natural); procedure SetRoot(BaseTree: in out Tree; Item: in Node_Pointer; NewColor: in Color := Color'First); procedure AddChild(BaseTree: in out Tree; Child: in TreePointer); procedure RemoveChild(BaseTree: in out Tree; Child: in integer); -- procedure RemoveChild(BaseTree: in out Tree; Child: in out Tree_List.Pointer); function GetRootData (BaseTree: in Tree) return Node_type; procedure SetColor (BaseTree: in out Tree; NewColor: in Color); private type Tree is record Data: Node_Pointer; NodeColor: Color; Children: Tree_List.List; end record; end Tree; -- The irony is, there ARE drugs that ENHANCE it. This says something profound about either science or medicine or people or muppets or all four. - S. John Ross