comp.lang.ada
 help / color / mirror / Atom feed
* coding problems, please help.
@ 2003-12-08 20:34 Ratson Janiv
  2003-12-08 21:31 ` Ratson Janiv
  0 siblings, 1 reply; 7+ messages in thread
From: Ratson Janiv @ 2003-12-08 20:34 UTC (permalink / raw)


with Jr.Queue;

with Jr.Queue.Max_Bounded_Queue;

use Jr.Queue.Max_Bounded_Queue;

procedure Q2 is

package My_Queue is new Max_Bounded_Queue(T=>Integer,">"=>">");


begin


null;

end Q2;

 compile error :

q2.adb:5:07: invalid prefix in selected component "Queue"

q2.adb:9:28: "Max_Bounded_Queue" is not visible

q2.adb:9:28: non-visible declaration at jr-queue-max_bounded_queue.ads:7

q2.adb:9:28: non-visible declaration at jr-queue-max_bounded_queue.ads:5

why ?

generic

   type T is private;

package Jr.Queue is
   type Queue is abstract tagged private;

   procedure Push(Q: in out Queue'class;Item:T) is abstract;
   procedure Pop(Q: in out Queue'class;Item:in out T) is abstract;
   function Empty(Q: Queue'class) return Boolean is abstract;

   private

      type Queue is tagged null record;

end Jr.Queue;



-------------------------

with Jr.Queue;

generic
package Jr.Queue.Max_Queue is

   type Max_Queue is abstract new Queue with null record;

   function Max(Q:Max_Queue) return T is abstract;

end Jr.queue.Max_Queue;


-----------------------

generic

   with function ">"(Item1,Item2:T) return Boolean;

package Jr.Queue.Max_Bounded_Queue is

   type Max_Bounded_Queue is new Queue with private;

   procedure Push(Q: in out Max_Bounded_Queue;Item:T);
   procedure Pop(Q: in out Max_Bounded_Queue;Item:in out T);
   function Empty(Q: Max_Bounded_Queue) return Boolean;
   function Max(Q:Max_Bounded_Queue) return T;

   Queue_Full, Queue_Empty :exception;

   private

   Num_Items : constant := 100;

   type Queue_Arr is array (1..Num_Items) of T;

   type Max_Bounded_Queue is new Queue with record
      Arr : Queue_Arr;
      I : Integer := 1;
      Max_Item : T;
   end record;

   procedure Find_Max(Q: in out Max_Bounded_Queue);

end Jr.Queue.Max_Bounded_Queue;



10x.





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

* Re: coding problems, please help.
  2003-12-08 20:34 coding problems, please help Ratson Janiv
@ 2003-12-08 21:31 ` Ratson Janiv
  2003-12-09  7:48   ` Petter Fryklund
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ratson Janiv @ 2003-12-08 21:31 UTC (permalink / raw)


I found something ...
Still having a problem ...
procedure Q2 is

    package My_Base_Queue is new Jr.Queue(T=>Integer);

    package My_Queue_Max is new My_Base_Queue(">"=>">");

begin

null;

end Q2;

Compile Error :

q2.adb:12:32: expect name of generic package in instantiation

Help Needed,
10x.


"Ratson Janiv" <janiv@013.net.il> wrote in message
news:3fd4e0e2$1@news.barak.net.il...
> with Jr.Queue;
>
> with Jr.Queue.Max_Bounded_Queue;
>
> use Jr.Queue.Max_Bounded_Queue;
>
> procedure Q2 is
>
> package My_Queue is new Max_Bounded_Queue(T=>Integer,">"=>">");
>
>
> begin
>
>
> null;
>
> end Q2;
>
>  compile error :
>
> q2.adb:5:07: invalid prefix in selected component "Queue"
>
> q2.adb:9:28: "Max_Bounded_Queue" is not visible
>
> q2.adb:9:28: non-visible declaration at jr-queue-max_bounded_queue.ads:7
>
> q2.adb:9:28: non-visible declaration at jr-queue-max_bounded_queue.ads:5
>
> why ?
>
> generic
>
>    type T is private;
>
> package Jr.Queue is
>    type Queue is abstract tagged private;
>
>    procedure Push(Q: in out Queue'class;Item:T) is abstract;
>    procedure Pop(Q: in out Queue'class;Item:in out T) is abstract;
>    function Empty(Q: Queue'class) return Boolean is abstract;
>
>    private
>
>       type Queue is tagged null record;
>
> end Jr.Queue;
>
>
>
> -------------------------
>
> with Jr.Queue;
>
> generic
> package Jr.Queue.Max_Queue is
>
>    type Max_Queue is abstract new Queue with null record;
>
>    function Max(Q:Max_Queue) return T is abstract;
>
> end Jr.queue.Max_Queue;
>
>
> -----------------------
>
> generic
>
>    with function ">"(Item1,Item2:T) return Boolean;
>
> package Jr.Queue.Max_Bounded_Queue is
>
>    type Max_Bounded_Queue is new Queue with private;
>
>    procedure Push(Q: in out Max_Bounded_Queue;Item:T);
>    procedure Pop(Q: in out Max_Bounded_Queue;Item:in out T);
>    function Empty(Q: Max_Bounded_Queue) return Boolean;
>    function Max(Q:Max_Bounded_Queue) return T;
>
>    Queue_Full, Queue_Empty :exception;
>
>    private
>
>    Num_Items : constant := 100;
>
>    type Queue_Arr is array (1..Num_Items) of T;
>
>    type Max_Bounded_Queue is new Queue with record
>       Arr : Queue_Arr;
>       I : Integer := 1;
>       Max_Item : T;
>    end record;
>
>    procedure Find_Max(Q: in out Max_Bounded_Queue);
>
> end Jr.Queue.Max_Bounded_Queue;
>
>
>
> 10x.
>
>





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

* Re: coding problems, please help.
  2003-12-08 21:31 ` Ratson Janiv
@ 2003-12-09  7:48   ` Petter Fryklund
  2003-12-09  8:40   ` Dmitry A. Kazakov
  2003-12-13 14:58   ` Ratson Janiv
  2 siblings, 0 replies; 7+ messages in thread
From: Petter Fryklund @ 2003-12-09  7:48 UTC (permalink / raw)


Since I beleive your working on an assignment, I'll only try to send
you off in the right direction.

Remove all use and use full names and you will see! Use should only be
used in declare blocks or very short subprograms in my opinion.

gl,
Petter




"Ratson Janiv" <janiv@013.net.il> wrote in message news:<3fd4ee3b$1@news.barak.net.il>...
> I found something ...
> Still having a problem ...
> procedure Q2 is
> 
>     package My_Base_Queue is new Jr.Queue(T=>Integer);
> 
>     package My_Queue_Max is new My_Base_Queue(">"=>">");
> 
> begin
> 
> null;
> 
> end Q2;
> 
> Compile Error :
> 
> q2.adb:12:32: expect name of generic package in instantiation
> 
> Help Needed,
> 10x.
> 
> 
> "Ratson Janiv" <janiv@013.net.il> wrote in message
> news:3fd4e0e2$1@news.barak.net.il...
> > with Jr.Queue;
> >
> > with Jr.Queue.Max_Bounded_Queue;
> >
> > use Jr.Queue.Max_Bounded_Queue;
> >
> > procedure Q2 is
> >
> > package My_Queue is new Max_Bounded_Queue(T=>Integer,">"=>">");
> >
> >
> > begin
> >
> >
> > null;
> >
> > end Q2;
> >
> >  compile error :
> >
> > q2.adb:5:07: invalid prefix in selected component "Queue"
> >
> > q2.adb:9:28: "Max_Bounded_Queue" is not visible
> >
> > q2.adb:9:28: non-visible declaration at jr-queue-max_bounded_queue.ads:7
> >
> > q2.adb:9:28: non-visible declaration at jr-queue-max_bounded_queue.ads:5
> >
> > why ?
> >
> > generic
> >
> >    type T is private;
> >
> > package Jr.Queue is
> >    type Queue is abstract tagged private;
> >
> >    procedure Push(Q: in out Queue'class;Item:T) is abstract;
> >    procedure Pop(Q: in out Queue'class;Item:in out T) is abstract;
> >    function Empty(Q: Queue'class) return Boolean is abstract;
> >
> >    private
> >
> >       type Queue is tagged null record;
> >
> > end Jr.Queue;
> >
> >
> >
> > -------------------------
> >
> > with Jr.Queue;
> >
> > generic
> > package Jr.Queue.Max_Queue is
> >
> >    type Max_Queue is abstract new Queue with null record;
> >
> >    function Max(Q:Max_Queue) return T is abstract;
> >
> > end Jr.queue.Max_Queue;
> >
> >
> > -----------------------
> >
> > generic
> >
> >    with function ">"(Item1,Item2:T) return Boolean;
> >
> > package Jr.Queue.Max_Bounded_Queue is
> >
> >    type Max_Bounded_Queue is new Queue with private;
> >
> >    procedure Push(Q: in out Max_Bounded_Queue;Item:T);
> >    procedure Pop(Q: in out Max_Bounded_Queue;Item:in out T);
> >    function Empty(Q: Max_Bounded_Queue) return Boolean;
> >    function Max(Q:Max_Bounded_Queue) return T;
> >
> >    Queue_Full, Queue_Empty :exception;
> >
> >    private
> >
> >    Num_Items : constant := 100;
> >
> >    type Queue_Arr is array (1..Num_Items) of T;
> >
> >    type Max_Bounded_Queue is new Queue with record
> >       Arr : Queue_Arr;
> >       I : Integer := 1;
> >       Max_Item : T;
> >    end record;
> >
> >    procedure Find_Max(Q: in out Max_Bounded_Queue);
> >
> > end Jr.Queue.Max_Bounded_Queue;
> >
> >
> >
> > 10x.
> >
> >



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

* Re: coding problems, please help.
  2003-12-08 21:31 ` Ratson Janiv
  2003-12-09  7:48   ` Petter Fryklund
@ 2003-12-09  8:40   ` Dmitry A. Kazakov
  2003-12-13 15:13     ` Mr. J.
  2003-12-13 14:58   ` Ratson Janiv
  2 siblings, 1 reply; 7+ messages in thread
From: Dmitry A. Kazakov @ 2003-12-09  8:40 UTC (permalink / raw)


On Mon, 8 Dec 2003 23:31:32 +0200, "Ratson Janiv" <janiv@013.net.il>
wrote:

>I found something ...
>Still having a problem ...
>procedure Q2 is
>
>    package My_Base_Queue is new Jr.Queue(T=>Integer);
>
>    package My_Queue_Max is new My_Base_Queue(">"=>">");

You are trying to instantiate a non-generic package (My_Base_Queue).

--
Regards,
Dmitry Kazakov
http://www.dmitry-kazakov.de



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

* Re: coding problems, please help.
  2003-12-08 21:31 ` Ratson Janiv
  2003-12-09  7:48   ` Petter Fryklund
  2003-12-09  8:40   ` Dmitry A. Kazakov
@ 2003-12-13 14:58   ` Ratson Janiv
  2 siblings, 0 replies; 7+ messages in thread
From: Ratson Janiv @ 2003-12-13 14:58 UTC (permalink / raw)


?

"Ratson Janiv" <janiv@013.net.il> wrote in message
news:3fd4ee3b$1@news.barak.net.il...
> I found something ...
> Still having a problem ...
> procedure Q2 is
>
>     package My_Base_Queue is new Jr.Queue(T=>Integer);
>
>     package My_Queue_Max is new My_Base_Queue(">"=>">");
>
> begin
>
> null;
>
> end Q2;
>
> Compile Error :
>
> q2.adb:12:32: expect name of generic package in instantiation
>
> Help Needed,
> 10x.
>
>
> "Ratson Janiv" <janiv@013.net.il> wrote in message
> news:3fd4e0e2$1@news.barak.net.il...
> > with Jr.Queue;
> >
> > with Jr.Queue.Max_Bounded_Queue;
> >
> > use Jr.Queue.Max_Bounded_Queue;
> >
> > procedure Q2 is
> >
> > package My_Queue is new Max_Bounded_Queue(T=>Integer,">"=>">");
> >
> >
> > begin
> >
> >
> > null;
> >
> > end Q2;
> >
> >  compile error :
> >
> > q2.adb:5:07: invalid prefix in selected component "Queue"
> >
> > q2.adb:9:28: "Max_Bounded_Queue" is not visible
> >
> > q2.adb:9:28: non-visible declaration at jr-queue-max_bounded_queue.ads:7
> >
> > q2.adb:9:28: non-visible declaration at jr-queue-max_bounded_queue.ads:5
> >
> > why ?
> >
> > generic
> >
> >    type T is private;
> >
> > package Jr.Queue is
> >    type Queue is abstract tagged private;
> >
> >    procedure Push(Q: in out Queue'class;Item:T) is abstract;
> >    procedure Pop(Q: in out Queue'class;Item:in out T) is abstract;
> >    function Empty(Q: Queue'class) return Boolean is abstract;
> >
> >    private
> >
> >       type Queue is tagged null record;
> >
> > end Jr.Queue;
> >
> >
> >
> > -------------------------
> >
> > with Jr.Queue;
> >
> > generic
> > package Jr.Queue.Max_Queue is
> >
> >    type Max_Queue is abstract new Queue with null record;
> >
> >    function Max(Q:Max_Queue) return T is abstract;
> >
> > end Jr.queue.Max_Queue;
> >
> >
> > -----------------------
> >
> > generic
> >
> >    with function ">"(Item1,Item2:T) return Boolean;
> >
> > package Jr.Queue.Max_Bounded_Queue is
> >
> >    type Max_Bounded_Queue is new Queue with private;
> >
> >    procedure Push(Q: in out Max_Bounded_Queue;Item:T);
> >    procedure Pop(Q: in out Max_Bounded_Queue;Item:in out T);
> >    function Empty(Q: Max_Bounded_Queue) return Boolean;
> >    function Max(Q:Max_Bounded_Queue) return T;
> >
> >    Queue_Full, Queue_Empty :exception;
> >
> >    private
> >
> >    Num_Items : constant := 100;
> >
> >    type Queue_Arr is array (1..Num_Items) of T;
> >
> >    type Max_Bounded_Queue is new Queue with record
> >       Arr : Queue_Arr;
> >       I : Integer := 1;
> >       Max_Item : T;
> >    end record;
> >
> >    procedure Find_Max(Q: in out Max_Bounded_Queue);
> >
> > end Jr.Queue.Max_Bounded_Queue;
> >
> >
> >
> > 10x.
> >
> >
>
>





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

* Re: coding problems, please help.
  2003-12-09  8:40   ` Dmitry A. Kazakov
@ 2003-12-13 15:13     ` Mr. J.
  2003-12-13 17:19       ` Dmitry A. Kazakov
  0 siblings, 1 reply; 7+ messages in thread
From: Mr. J. @ 2003-12-13 15:13 UTC (permalink / raw)


Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote in message news:<fh2btv8t6kopeec1mqgub87fr600s54qnu@4ax.com>...
> On Mon, 8 Dec 2003 23:31:32 +0200, "Ratson Janiv" <janiv@013.net.il>
> wrote:
> 
> >I found something ...
> >Still having a problem ...
> >procedure Q2 is
> >
> >    package My_Base_Queue is new Jr.Queue(T=>Integer);
> >
> >    package My_Queue_Max is new My_Base_Queue(">"=>">");
> 
> You are trying to instantiate a non-generic package (My_Base_Queue).

I guess so, but Jr.Queue is a generic package, so how do I define the
My_Best_Queue as a generic package ?

10x,
J.



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

* Re: coding problems, please help.
  2003-12-13 15:13     ` Mr. J.
@ 2003-12-13 17:19       ` Dmitry A. Kazakov
  0 siblings, 0 replies; 7+ messages in thread
From: Dmitry A. Kazakov @ 2003-12-13 17:19 UTC (permalink / raw)


Mr. J. wrote:

> Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote in message
> news:<fh2btv8t6kopeec1mqgub87fr600s54qnu@4ax.com>...
>> On Mon, 8 Dec 2003 23:31:32 +0200, "Ratson Janiv" <janiv@013.net.il>
>> wrote:
>> 
>> >I found something ...
>> >Still having a problem ...
>> >procedure Q2 is
>> >
>> >    package My_Base_Queue is new Jr.Queue(T=>Integer);
>> >
>> >    package My_Queue_Max is new My_Base_Queue(">"=>">");
>> 
>> You are trying to instantiate a non-generic package (My_Base_Queue).
> 
> I guess so, but Jr.Queue is a generic package, so how do I define the
> My_Best_Queue as a generic package ?

It depends on what you want. I can only guess that you are probably longing
for a sort of generic specialization:

1. A generic child of Jr.Queue

generic
   with function ">" (L, R : T) return Boolean is <>;
package Jr.Queue.Ordered is
   ...

2. A generic package parametrized by an instance of Jr.Queue

generic
   type T is private;
   with function ">" (L, R : T) return Boolean is <>;
   with package Some_Queue is new Jr.Queue (T);
package Ordered_Queue is
   ...

etc.

-- 
Regards,
Dmitry A. Kazakov
www.dmitry-kazakov.de



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

end of thread, other threads:[~2003-12-13 17:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-08 20:34 coding problems, please help Ratson Janiv
2003-12-08 21:31 ` Ratson Janiv
2003-12-09  7:48   ` Petter Fryklund
2003-12-09  8:40   ` Dmitry A. Kazakov
2003-12-13 15:13     ` Mr. J.
2003-12-13 17:19       ` Dmitry A. Kazakov
2003-12-13 14:58   ` Ratson Janiv

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