comp.lang.ada
 help / color / mirror / Atom feed
* accessibility of objects
@ 2010-12-04 22:17 george
  2010-12-04 23:35 ` Ludovic Brenta
  2010-12-05 10:16 ` Georg Bauhaus
  0 siblings, 2 replies; 3+ messages in thread
From: george @ 2010-12-04 22:17 UTC (permalink / raw)


Hello, I have been wrestling with an issue for some time, and now Im looking for if someone has a good solution.

I what to have a "package" where i have routins that I want to call from another code/package. while this first package need to store items/records that are defined in the calling package. Ada just wont let me do such construct, what shall I use. I typically get
"type extension at deeper accessibility level than parent" or something else problem. 
I just want this utility program to store essentially in old language a pointer to my object, and dont care about the structure of the object, and then return me the pointer att appropriate time. 






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

* Re: accessibility of objects
  2010-12-04 22:17 accessibility of objects george
@ 2010-12-04 23:35 ` Ludovic Brenta
  2010-12-05 10:16 ` Georg Bauhaus
  1 sibling, 0 replies; 3+ messages in thread
From: Ludovic Brenta @ 2010-12-04 23:35 UTC (permalink / raw)


george <user@compgroups.net/> writes on comp.lang.ada:
> Hello, I have been wrestling with an issue for some time, and now Im
> looking for if someone has a good solution.
>
> I what to have a "package" where i have routins that I want to call
> from another code/package. while this first package need to store
> items/records that are defined in the calling package. Ada just wont
> let me do such construct, what shall I use. I typically get "type
> extension at deeper accessibility level than parent" or something else
> problem.  I just want this utility program to store essentially in old
> language a pointer to my object, and dont care about the structure of
> the object, and then return me the pointer att appropriate time.

How many objects does your package need to store?

If the answer is only 1 then that's a singleton and you probably don't
need any pointers or access values at all.

If the answer is "many" then I suggest you use a predefined container.
Ada 2005 has a selection of Vectors, Maps, Sets, Ordered_Sets and
Doubly_Linked_Lists; see section A.18 in the Ada 2005 Reference Manual
[1].  If you use a compiler that only supports Ada 95 then I recommend
you use the Charles library [2].

[1] http://www.adaic.com/standards/05rm/html/RM-TOC.html
[2] http://charles.tigris.org/

HTH

-- 
Ludovic Brenta.



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

* Re: accessibility of objects
  2010-12-04 22:17 accessibility of objects george
  2010-12-04 23:35 ` Ludovic Brenta
@ 2010-12-05 10:16 ` Georg Bauhaus
  1 sibling, 0 replies; 3+ messages in thread
From: Georg Bauhaus @ 2010-12-05 10:16 UTC (permalink / raw)


On 12/4/10 11:17 PM, george wrote:
> ... this first package need to store items/records that are defined in the calling package.
> "type extension at deeper accessibility level than parent" or something else problem.
> I just want this utility program to store essentially in old language a pointer to my object, and dont care about the structure of the object, and then return me the pointer att appropriate time.

A message like this may mean two things:

1. there is a derived type L defined local
to some subprogram.

2. an object of this local type L has been
allocated and is to be referred to from the
outside.

That is, some place more global, perhaps your package,
defines the ancestor type P of L. Maybe some type
of pointers to P'Class, too, say Ref.

If you'd to try to assign the local object to a
pointer of global type Ref then after the subprogram
has finished, the pointer would be pointing to an
object whose type no longer exists, since its type  (L)
was defined local to this subprogram.

In this case, you'd need to view convert the local object
of type L to an object of the ancestor type P (using a view
conversion) and then take its pointer.

(What software are you using for posting? NNTP
clients respect very long lines; this renders
quoting a bit difficult.)



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

end of thread, other threads:[~2010-12-05 10:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-04 22:17 accessibility of objects george
2010-12-04 23:35 ` Ludovic Brenta
2010-12-05 10:16 ` Georg Bauhaus

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