comp.lang.ada
 help / color / mirror / Atom feed
* Re: I have a question about the "record" in ADA
  1999-05-21  0:00 I have a question about the "record" in ADA mike
@ 1999-05-21  0:00 ` dennison
  1999-05-22  0:00 ` Dale Stanbrough
  1999-06-03  0:00 ` Matthew Heaney
  2 siblings, 0 replies; 4+ messages in thread
From: dennison @ 1999-05-21  0:00 UTC (permalink / raw)


In article <7i453r$l5m$1@wanadoo.fr>,
  "mike" <blsoul@hotmail.com> wrote:
> Sorry for my bad English :)
> How could I do to access to the different part of a record which is
> a generic parameter in a generic package?
> because my function in my package must acces in the record.

I am indeed having trouble with either your English or your terminology.
Perhaps you should try to post some Ada source code with an explanation
of what you are trying to do.

--
T.E.D.


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---




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

* I have a question about the "record" in ADA
@ 1999-05-21  0:00 mike
  1999-05-21  0:00 ` dennison
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mike @ 1999-05-21  0:00 UTC (permalink / raw)


Sorry for my bad English :)
How could I do to access to the different part of a record which is
a generic parameter in a generic package?
because my function in my package must acces in the record.
Mike







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

* Re: I have a question about the "record" in ADA
  1999-05-21  0:00 I have a question about the "record" in ADA mike
  1999-05-21  0:00 ` dennison
@ 1999-05-22  0:00 ` Dale Stanbrough
  1999-06-03  0:00 ` Matthew Heaney
  2 siblings, 0 replies; 4+ messages in thread
From: Dale Stanbrough @ 1999-05-22  0:00 UTC (permalink / raw)


In article <7i453r$l5m$1@wanadoo.fr>, "mike" <blsoul@hotmail.com> wrote:

> Sorry for my bad English :)
> How could I do to access to the different part of a record which is
> a generic parameter in a generic package?
> because my function in my package must acces in the record.
> Mike



If you want to access particular fields, then you don't _really_
want to pass in any record (i.e. you don't want it as a generic
parameter), you are wanting to pass in a -particular- record.
Otherwise how in the world would you know what fields are in there?

Solutions are...

You can modify the parameters to the subprograms in the generic to
include the record type you want to access.


You can pass in a _particular_ tagged type record as a generic 
parameter.

   generic
      type Element is new Root_Type with private;

(i think!)


You could pass in accessor functions that will extract the information
you want out of the generic parameter.
e.g.
   generic
      type element is private;
      with function Get_Field1 (Item : Element) return X;
      with function Get_Field2 (Item : Element) return Y;
      etc.


Dale




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

* Re: I have a question about the "record" in ADA
  1999-05-21  0:00 I have a question about the "record" in ADA mike
  1999-05-21  0:00 ` dennison
  1999-05-22  0:00 ` Dale Stanbrough
@ 1999-06-03  0:00 ` Matthew Heaney
  2 siblings, 0 replies; 4+ messages in thread
From: Matthew Heaney @ 1999-06-03  0:00 UTC (permalink / raw)


"mike" <blsoul@hotmail.com> writes:

> Sorry for my bad English :)
> How could I do to access to the different part of a record which is
> a generic parameter in a generic package?
> because my function in my package must acces in the record.
> Mike

One way is to just declare the record type in its own package:

  package RP is

    type RT is 
      record
        X, Y : Integer;
      end record;

  end RP;


  with RP;
  generic
    ...
  package GP is ...;


If the record type is itself part of a generic package, then you can
import an instantiation:

  generic
    ...
  package GRP is

    type RT is record ...;

  end GRP;


  with GRP;
  generic
    with package RP is new GRP (...);
    ...
  package GP is ...;



See also the Strategy example in the ACM patterns archive.  A storage
management package imports a storage node (record) type using the
technique described above.

<http://www.acm.org/archives/patterns.html>

    




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

end of thread, other threads:[~1999-06-03  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-21  0:00 I have a question about the "record" in ADA mike
1999-05-21  0:00 ` dennison
1999-05-22  0:00 ` Dale Stanbrough
1999-06-03  0:00 ` Matthew Heaney

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