From: David Starner <dstarner98@aasaa.ofe.org>
To: "James S. Rogers" <jimmaureenrogers@worldnet.att.net>
Subject: Re: First attribute on Enumerated types
Date: 1999/02/23
Date: 1999-02-23T00:00:00+00:00 [thread overview]
Message-ID: <36D3678F.6C3CB1F6@aasaa.ofe.org> (raw)
In-Reply-To: 001e01be5f9d$ebe4d7e0$5b824a0c@rogers
"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 <dstarner98@aasaa.ofe.org>>
> >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
next parent reply other threads:[~1999-02-23 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <001e01be5f9d$ebe4d7e0$5b824a0c@rogers>
1999-02-23 0:00 ` David Starner [this message]
1999-02-24 0:00 ` First attribute on Enumerated types Mark A Biggar
1999-02-24 0:00 ` Matthew Heaney
1999-02-24 0:00 ` John English
1999-02-23 0:00 David Starner
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox