comp.lang.ada
 help / color / mirror / Atom feed
* Re: newbie to generic
@ 2002-05-17  9:26 Grein, Christoph
  0 siblings, 0 replies; 3+ messages in thread
From: Grein, Christoph @ 2002-05-17  9:26 UTC (permalink / raw)


> whats wring with this?
> 
> function To_Add is new
> System.Address_To_Access_Conversions.To_Address(Procedure_Ptr_Type);
> 
> "Procedure_Ptr_Type" is my Object.
> 


System.Address_To_Access_Conversions is a generic package and you habe to 
instantiate to create a package. After instantiation, the instance package holds 
functions that you can call like any other function of a "normal" package.

package My_Conversion is new System.Address_To_Access_Conversions (My_Type);

X := My_Conversion.To_Address (Procedure_Ptr_Type);



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

* Re: newbie to generic
       [not found] <ac2hbs$ljq$1@newstoo.ericsson.se>
@ 2002-05-17  9:35 ` Preben Randhol
  2002-05-17 19:40 ` Jeffrey Carter
  1 sibling, 0 replies; 3+ messages in thread
From: Preben Randhol @ 2002-05-17  9:35 UTC (permalink / raw)


On Fri, 17 May 2002 11:13:12 +0200, Sebastian wrote:

> whats wring with this?

First stop posting HTML to a news group. Turn on text only in your
newsreader.

> function To_Add is new =
> System.Address_To_Access_Conversions.To_Address(Procedure_Ptr_Type);

because the package System.Address_To_Access_Conversions is defined as
this (arm95 - 13.7.2):

  generic
     type Object(<>) is limited private;
  package System.Address_To_Access_Conversions
  is
  pragma Preelaborate(Address_To_Access_Conversions);
  type Object_Pointer is access all Object;
  [...]
  function To_Address(Value : Object_Pointer) return Address;
  [...]
  end System.Address_To_Access_Conversions;


This means that you have to do:

   package My_Address_Conversion is 
      new System.Address_To_Access_Conversions (Object => Procedure_Type);

and then you call To_Address like this:

   My_Address_Conversion.To_Address(Procedure_Ptr_Type);

-- 
Preben



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

* Re: newbie to generic
       [not found] <ac2hbs$ljq$1@newstoo.ericsson.se>
  2002-05-17  9:35 ` newbie to generic Preben Randhol
@ 2002-05-17 19:40 ` Jeffrey Carter
  1 sibling, 0 replies; 3+ messages in thread
From: Jeffrey Carter @ 2002-05-17 19:40 UTC (permalink / raw)


> Sebastian wrote:
> 
> whats wring with this?
> 
> function To_Add is new
> System.Address_To_Access_Conversions.To_Address(Procedure_Ptr_Type);
> 
> "Procedure_Ptr_Type" is my Object.

Why do you want to mess with addresses? If you don't understand generics
yet, you are unlikely to understand the very few circumstances in which
you need to deal with addresses in Ada.

-- 
Jeff Carter
"Monsieur Arthur King, who has the brain of a duck, you know."
Monty Python & the Holy Grail



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

end of thread, other threads:[~2002-05-17 19:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <ac2hbs$ljq$1@newstoo.ericsson.se>
2002-05-17  9:35 ` newbie to generic Preben Randhol
2002-05-17 19:40 ` Jeffrey Carter
2002-05-17  9:26 Grein, Christoph

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