comp.lang.ada
 help / color / mirror / Atom feed
From: jpwoodruff@irisinternet.net (John Woodruff)
Subject: Re: generic and visibility
Date: 4 Nov 2004 19:39:37 -0800
Date: 2004-11-04T19:39:37-08:00	[thread overview]
Message-ID: <34defe4d.0411041939.2969990@posting.google.com> (raw)
In-Reply-To: 1099581795.057353.199160@c13g2000cwb.googlegroups.com

"mferracini" <maurizio.ferracini@gmail.com> wrote in message news:<1099581795.057353.199160@c13g2000cwb.googlegroups.com>...
> i'm new on ADA, and i hav some problem
> with generic.
> 
> this is an exemple
> 
> 
> 
> ------------------------------------
> package Manage is
> generic
> Id : integer;
> with procedure Init;
> with procedure Job;
> package Det is
> 
> procedure Start(
> Status :    out Integer );
> end Det;
> end Manage;
> 
> ----------------------------------------
> 
> with Ada.Text_Io;
> with Ada.Task_Identification;
> 
> package body Applicazione is
> I : Integer := 0;
> 
> procedure Init is
> begin
> I:=1;
> end Init;
> 
> procedure Job is
> begin
> Ada.Text_Io.Put(Item => "> mi sbatto!  ");
> I:=I+1;
> Ada.Text_Io.Put(Item => Integer'Image (I));
> Ada.Text_Io.New_Line;
> end Job;
> 
> end Applicazione;
> -----------------------------------------
> 
> with Manage;
> with Applicazione;
> 
> 
> package Fake_App is new Manage_Task.Det_Task_M_Pack
> (
> Id_task => 1,
> Init_Job => Applicazione.Init,
> Job => Applicazione.Job);
> 
> ---------------
> 
> 
> with Fake_App;
> 
> procedure Test is
> begin
> Fake_app.job;
> end Test;
> 
> ---------------------------------------------------------------------------------
> job in not a visible entry of fake_app
> 
> how i can do?
> thanks

I'm guessing "homework" here, so I'll give (I hope) constructive
hints, but not solve the problem completely ----

You have omitted a couple items that are needed before I can answer
your direct question.

You need to give a specification for the package Applicazione.  You
gave only a body, and every package needs a spec (most need a body as
well). 

It probably looks like this:

package Applicazione is
  procedure Init ;
  procedure Job ;
end Applicazione;
-----

Next, your package that you call "Fake_App" is not correct.  Manage
contains an internal package called Det.  So you need to "instantiate"
that internal package by naming it properly when you say something
like

  package Fake_App is new <<correct name here>> with its parameters.
-----

Then finally, why are you unable to find an entry "job" in the
instance called Fake_App?

When you make a new instance (the thing you're calling Fake_App),
it has the  subprograms that were visible in its spec.  Start is the
ONLY visible subprogram declared.  Consider the difference between the
generic formal procedure "Job" and the procedure Start.   

HTH
John



  parent reply	other threads:[~2004-11-05  3:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-04 15:23 generic and visibility mferracini
2004-11-04 18:59 ` Georg Bauhaus
2004-11-05  3:39 ` John Woodruff [this message]
  -- strict thread matches above, loose matches on Subject: below --
2005-06-10 21:34 Generic " e.coli
2005-06-11  1:18 ` Larry Hazel
2005-06-11  4:44 ` Preben Randhol
replies disabled

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