comp.lang.ada
 help / color / mirror / Atom feed
* Generic,procedure and visibility.
@ 2004-11-25 16:36 mferracini
  2004-11-25 16:53 ` mferracini
  2004-11-25 18:20 ` Georg Bauhaus
  0 siblings, 2 replies; 7+ messages in thread
From: mferracini @ 2004-11-25 16:36 UTC (permalink / raw)


sorry for the italian-naming :)

package Generico is
generic
with procedure Lavora;
package Nascosto is
procedure Inizia;
end Nascosto;
end Generico;

package body Generico is

package body Nascosto is
procedure Inizia is
begin
Lavora;
end Inizia;
end Nascosto;

begin
lavora;  --error:"lavora" in not visibile
end Generico;
why "lavora" is only visible by pakage "Nascosto" ?
thanks




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

* Re: Generic,procedure and visibility.
  2004-11-25 16:36 Generic,procedure and visibility mferracini
@ 2004-11-25 16:53 ` mferracini
  2004-11-25 19:15   ` Stephen Leake
  2004-11-25 18:20 ` Georg Bauhaus
  1 sibling, 1 reply; 7+ messages in thread
From: mferracini @ 2004-11-25 16:53 UTC (permalink / raw)


now see this new case:

package Generico is
generic
with procedure Lavora;
package Nascosto is
procedure Inizia;
end Nascosto;
end Generico;

package body Generico is

package body Nascosto is

task type Pippo is
entry Fai;
end Pippo;

task body Pippo is
begin
accept Fai;
Lavora;
end Pippo;

type P_Pippo is access Pippo;
x:p_pippo;

procedure Inizia is
begin
X:=new Pippo;
X.Fai;
end Inizia;
end Nascosto;

begin
null;
end Generico;

--------------------------
evry time that call i [thing that is a new generico.nascosto].inizia
a new task born.

so i want to create a array of this task for manage them.
how i can do?

thanks




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

* Re: Generic,procedure and visibility.
  2004-11-25 16:36 Generic,procedure and visibility mferracini
  2004-11-25 16:53 ` mferracini
@ 2004-11-25 18:20 ` Georg Bauhaus
  1 sibling, 0 replies; 7+ messages in thread
From: Georg Bauhaus @ 2004-11-25 18:20 UTC (permalink / raw)


mferracini <maurizio.ferracini@gmail.com> wrote:

Lovora is the name of a formal parameter of Nascosto.
Therefore the name denotes something if it is used inside
Nascosto.

Do you want to call the subprogram that is to
become the actual parameter value of Lovora?
Where is it?



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

* Re: Generic,procedure and visibility.
  2004-11-25 16:53 ` mferracini
@ 2004-11-25 19:15   ` Stephen Leake
  2004-11-25 20:27     ` Jeffrey Carter
  2004-11-29 16:29     ` mferracini
  0 siblings, 2 replies; 7+ messages in thread
From: Stephen Leake @ 2004-11-25 19:15 UTC (permalink / raw)
  To: comp.lang.ada

"mferracini" <maurizio.ferracini@gmail.com> writes:

> now see this new case:
> 
> package Generico is
> generic
> with procedure Lavora;
> package Nascosto is
> procedure Inizia;
> end Nascosto;
> end Generico;

Please use standard indentation; it makes things much easier to read:

package Generico is
   generic
      with procedure Lavora;
   package Nascosto is
      procedure Inizia;
   end Nascosto;
end Generico;

package body Generico is

   package body Nascosto is

      task type Pippo is
         entry Fai;
      end Pippo;

      task body Pippo is
      begin
         accept Fai;
         Lavora;
      end Pippo;

      type P_Pippo is access Pippo;
      x:p_pippo;

      procedure Inizia is
      begin
         X:=new Pippo;
         X.Fai;
      end Inizia;
   end Nascosto;

begin
   null;
end Generico;

Note that you _don't_ need the "begin null;" at the end of the
package; that is optional, and should only be there if it does some
initialization.


> evry time that call i [thing that is a new generico.nascosto].inizia
> a new task born.

Yes; X := new Pippo; creates a new task.

> so i want to create a array of this task for manage them.
> how i can do?

type Task_Array is array (1 .. 10) of P_Pippo;

Have Inizia return the pointer it creates, so the user can store it in
the array.

-- 
-- Stephe




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

* Re: Generic,procedure and visibility.
  2004-11-25 19:15   ` Stephen Leake
@ 2004-11-25 20:27     ` Jeffrey Carter
  2004-11-29 16:29     ` mferracini
  1 sibling, 0 replies; 7+ messages in thread
From: Jeffrey Carter @ 2004-11-25 20:27 UTC (permalink / raw)


Stephen Leake wrote:

> Please use standard indentation; it makes things much easier to read:

While I agree, I also am aware that some mailers de-indent things.

>>so i want to create a array of this task for manage them.
>>how i can do?
> 
> type Task_Array is array (1 .. 10) of P_Pippo;

This declares an array type with access components. To have task 
components, it would be

type Task_Array is array (...) of Pippo;

-- 
Jeff Carter
"In the frozen land of Nador they were forced to
eat Robin's minstrels, and there was much rejoicing."
Monty Python & the Holy Grail
70




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

* Re: Generic,procedure and visibility.
  2004-11-25 19:15   ` Stephen Leake
  2004-11-25 20:27     ` Jeffrey Carter
@ 2004-11-29 16:29     ` mferracini
  2004-11-29 21:47       ` Stephen Leake
  1 sibling, 1 reply; 7+ messages in thread
From: mferracini @ 2004-11-29 16:29 UTC (permalink / raw)



Stephen Leake wrote:


> > evry time that call i [thing that is a new
generico.nascosto].inizia
> > a new task born.
>
> Yes; X := new Pippo; creates a new task.
>
> > so i want to create a array of this task for manage them.
> > how i can do?
>
> type Task_Array is array (1 .. 10) of P_Pippo;
>
> Have Inizia return the pointer it creates, so the user can store it
in
> the array.

thanks, but
type P_Pippo is visible only in Nascosto.
how export the task pointer outside the package?

maurizio




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

* Re: Generic,procedure and visibility.
  2004-11-29 16:29     ` mferracini
@ 2004-11-29 21:47       ` Stephen Leake
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Leake @ 2004-11-29 21:47 UTC (permalink / raw)
  To: comp.lang.ada

"mferracini" <maurizio.ferracini@gmail.com> writes:

> type P_Pippo is visible only in Nascosto.
> how export the task pointer outside the package?

In general, types must be declared in a place where they are visible
in all the places they need to be. 

So if P_Pippo needs to be visible outside of Nascosto, it must be
declared in the spec of Nascosto.

-- 
-- Stephe




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

end of thread, other threads:[~2004-11-29 21:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-25 16:36 Generic,procedure and visibility mferracini
2004-11-25 16:53 ` mferracini
2004-11-25 19:15   ` Stephen Leake
2004-11-25 20:27     ` Jeffrey Carter
2004-11-29 16:29     ` mferracini
2004-11-29 21:47       ` Stephen Leake
2004-11-25 18:20 ` Georg Bauhaus

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