comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey Creem" <jeff@thecreems.com>
Subject: Re: A little help on Generics.
Date: Mon, 24 Jun 2002 20:21:38 GMT
Date: 2002-06-24T20:21:38+00:00	[thread overview]
Message-ID: <mbLR8.309025$cQ3.16715@sccrnsc01> (raw)
In-Reply-To: ORJR8.298791$352.29149@sccrnsc02

Ok..In any case your first real problem is with the instantiation which
should look
like the one i gave you v.s. the one you used.

There are several things wrong with the body (not using Max, not actually
filling
in the next fields on pushes... a few others as well...)

This seems an aweful lot like a homework assignment...Is it?

"Caffeine Junky" <nospam@hotmail.com> wrote in message
news:ORJR8.298791$352.29149@sccrnsc02...
> On Mon, 24 Jun 2002 06:49:07 -0400, Jeffrey
>
> > Since you did not post the body you may have other problems here but the
> > first I see is the
> > syntax here.  Try something like
> >
> > package Int_Stack is new genstack(Max => 500, Item => Integer);
> >
> >
> > Also, try to avoid the 'img attribute even in your test code..It is a
> > handy feature
> > but is not portable..It is a nice trick to have up your sleeve but it is
> > only a few
> > more kestrokes to type integer'image(ints(J)).
> >
> > I there are a few more problems lurking in that test driver as well but
> > I am sure you will find these soon enough.
>
> I dont seem to be having any problems with the body of the package, it
> was just with the declaration of the package.
>
> The only errors the compiler gave me told me that procedure Push was not
> visible, Pop was not visible, etc...
>
> However when running the compiler over just the package, it produces a
> nice object file. Which leads me to beleive that my problem is in
> calling the package from my test program rather than in the package
> itself.
>
> However, just to be sure, here is a copy of the body of the package...
>
> package body genstack is
>
>    procedure Push(X : in Item; S : in out Stack) is
>
>    begin
>
>       S := new Cell'(X, S);
>
>    end Push;
>
>    function Pop(S : in Stack) return Item is
>
>       G : Item;
>
>    begin
>
>       G := S.Value;
>       S := S.Next;
>       return G;
>
>    end Pop;
>
>    function Is_Empty(S : in Stack) return Boolean is
>
>    begin
>
>       if S.Next = null then
>          return True;
>       else
>          return False;
>       end if;
>
>    end Is_Empty;
>
> end genstack;
>
>
>
>
> Any pointers would be appreciated, as usual.
>
>
> St4pL3





  reply	other threads:[~2002-06-24 20:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-24  6:15 A little help on Generics Caffeine Junky
2002-06-24  7:34 ` Dale Stanbrough
2002-06-24 10:49 ` Jeffrey Creem
2002-06-24 18:50   ` Caffeine Junky
2002-06-24 20:21     ` Jeffrey Creem [this message]
2002-06-24 22:29       ` Caffeine Junky
2002-06-25  2:52 ` SteveD
2002-06-25  7:25   ` Caffeine Junky
replies disabled

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