comp.lang.ada
 help / color / mirror / Atom feed
* Problem with access types using Booch components.
@ 2003-02-11 18:21 Jano
  2003-02-11 18:49 ` Jano
  2003-02-11 20:42 ` Simon Wright
  0 siblings, 2 replies; 7+ messages in thread
From: Jano @ 2003-02-11 18:21 UTC (permalink / raw)


Hello, I'm trying to use these and I've come across this problem.

Say I have a Collection type completely instantiated:

subtype Collection_x is Abstract_x_collections.Collection;

and I define

type Collection_x_access is access all Collection_x;

Now I have a

C: Collection_x;
C_access: Collection_x_access:= C'access;

All works well until I try to create an iterator:

first try:
it: Iterator:= New_iterator(C_access.all); <-- it raises tag error
inside some booch source.

second try:
it: Iterator:= New_iterator(Collection_x(C_access.all)); <-- same as
above.

third try:
C_bis: Collection_x:= C_access.all;
it: Iterator:= New_iterator(C_bis); <-- It works!!

I would go with the first option.

I'm 99% sure that I'm calling the proper functions in the proper
packages, but if anyone demands it, I can post a more detailed example
with actual code.

What's happening??

(In a side note, in the first of the three calls, if I replace
C_access.all by
 C_access (yes!), Gnat compiles without complaint...)

Regards,

Alex.



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

* Re: Problem with access types using Booch components.
  2003-02-11 18:21 Problem with access types using Booch components Jano
@ 2003-02-11 18:49 ` Jano
  2003-02-11 20:42 ` Simon Wright
  1 sibling, 0 replies; 7+ messages in thread
From: Jano @ 2003-02-11 18:49 UTC (permalink / raw)


En el mensaje <5d6fdb61.0302111021.73b4bc4a@posting.google.com>, 402450
@cepsz.unizar.es dice...
> Hello, I'm trying to use these and I've come across this problem.
> 
> Say I have a Collection type completely instantiated:
> 
> subtype Collection_x is Abstract_x_collections.Collection;

Sorry, my typo: this subtype renames the one contained in the third 
instantation:

Package Abstract_container is new...
Package Abstract_collection is new...
Package X_collections is new...

subtype Collection_x is X_collections.Collection;

> 
> and I define
> 
> type Collection_x_access is access all Collection_x;
> 
> Now I have a
> 
> C: Collection_x;
> C_access: Collection_x_access:= C'access;
> 
> All works well until I try to create an iterator:
> 
> first try:
> it: Iterator:= New_iterator(C_access.all); <-- it raises tag error
> inside some booch source.
> 
> second try:
> it: Iterator:= New_iterator(Collection_x(C_access.all)); <-- same as
> above.
> 
> third try:
> C_bis: Collection_x:= C_access.all;
> it: Iterator:= New_iterator(C_bis); <-- It works!!
> 
> I would go with the first option.
> 
> I'm 99% sure that I'm calling the proper functions in the proper
> packages, but if anyone demands it, I can post a more detailed example
> with actual code.
> 
> What's happening??
> 
> (In a side note, in the first of the three calls, if I replace
> C_access.all by
>  C_access (yes!), Gnat compiles without complaint...)
> 
> Regards,
> 
> Alex.
> 

-- 
-------------------------
Jano
402450[at]cepsz.unizar.es
-------------------------



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

* Re: Problem with access types using Booch components.
  2003-02-11 18:21 Problem with access types using Booch components Jano
  2003-02-11 18:49 ` Jano
@ 2003-02-11 20:42 ` Simon Wright
  2003-02-11 22:46   ` Jano
  1 sibling, 1 reply; 7+ messages in thread
From: Simon Wright @ 2003-02-11 20:42 UTC (permalink / raw)


402450@cepsz.unizar.es (Jano) writes:

> first try:
> it: Iterator:= New_iterator(C_access.all); <-- it raises tag error
> inside some booch source.

What compiler/version are you using?

With GNAT 3.15p I get this to compile without complaint (and to run,
though it's not a thorough test!).

Note the 'Class ....



with Collection_Test_Support;

procedure Jano is

   use Collection_Test_Support;

   type CU_P is access all CU.Collection;

   C : aliased CU.Collection;
   CP : CU_P := C'Access;

begin

   declare
      It : Containers.Iterator'Class := CU.New_Iterator (CP.all);
   begin
      null;
   end;

end Jano;




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

* Re: Problem with access types using Booch components.
  2003-02-11 20:42 ` Simon Wright
@ 2003-02-11 22:46   ` Jano
  2003-02-12  9:06     ` Jano
  0 siblings, 1 reply; 7+ messages in thread
From: Jano @ 2003-02-11 22:46 UTC (permalink / raw)


En el mensaje <x7vsmuu7dn9.fsf@smaug.pushface.org>, simon@pushface.org 
dice...

Hello,

> What compiler/version are you using?

I'm using Gnat 3.15p

> With GNAT 3.15p I get this to compile without complaint (and to run,
> though it's not a thorough test!).

Mmm, I get it also to compile, it's only at runtime that I get the 
Constraint_error exception raised, saying "tag check failed" or the like 
(sorry, I'm not at work where I have the sources to quote it exactly)

> Note the 'Class ....

I've noted it. Really, I was following the example in the docs very 
closely because I've just begun to try it.

Your example below it's exactly what I have, but I have it splitted 
across some packages. I find it strange, specially because of the error 
going away when I assign the access to a local container.

Uhm! I see now a difference. You are getting the iterator from CU, which 
is the unit who contains the type Collection. In the example in the docs 
(and in my program) I'm getting the Iterator from the top 
abstract_container. I suppose dispatching takes care of this? But what 
about the different behavior in my case when using the access or the 
local container?

Thanks anyway, I'll try tomorrow to use the CU-level package...

> with Collection_Test_Support;
> 
> procedure Jano is
> 
>    use Collection_Test_Support;
> 
>    type CU_P is access all CU.Collection;
> 
>    C : aliased CU.Collection;
>    CP : CU_P := C'Access;
> 
> begin
> 
>    declare
>       It : Containers.Iterator'Class := CU.New_Iterator (CP.all);
>    begin
>       null;
>    end;
> 
> end Jano;

-- 
-------------------------
Jano
402450[at]cepsz.unizar.es
-------------------------



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

* Re: Problem with access types using Booch components.
  2003-02-11 22:46   ` Jano
@ 2003-02-12  9:06     ` Jano
  2003-02-12 21:57       ` Simon Wright
  0 siblings, 1 reply; 7+ messages in thread
From: Jano @ 2003-02-12  9:06 UTC (permalink / raw)


Jano <402450@cepsz.unizar.es> wrote in message news:<MPG.18b39bca994daf55989693@News.CIS.DFN.DE>...
> En el mensaje <x7vsmuu7dn9.fsf@smaug.pushface.org>, simon@pushface.org 
> dice...
> 
> Hello,
> 
> > What compiler/version are you using?
> 
> I'm using Gnat 3.15p
> 
> > With GNAT 3.15p I get this to compile without complaint (and to run,
> > though it's not a thorough test!).
> 
> Mmm, I get it also to compile, it's only at runtime that I get the 
> Constraint_error exception raised, saying "tag check failed" or the like 
> (sorry, I'm not at work where I have the sources to quote it exactly)
> 
> > Note the 'Class ....
> 
> I've noted it. Really, I was following the example in the docs very 
> closely because I've just begun to try it.
> 
> Your example below it's exactly what I have, but I have it splitted 
> across some packages. I find it strange, specially because of the error 
> going away when I assign the access to a local container.
> 
> Uhm! I see now a difference. You are getting the iterator from CU, which 
> is the unit who contains the type Collection. In the example in the docs 
> (and in my program) I'm getting the Iterator from the top 
> abstract_container. I suppose dispatching takes care of this? But what 
> about the different behavior in my case when using the access or the 
> local container?

ARG! MY MEMORY FAULT ANOTHER TIME. I was taking the iterator from the
same package you are. So the problem remains equal.

Now I have the exact error wording:

CONSTRAINT_ERROR: bc-containers-collections.adb:93 tag check failed

> Thanks anyway, I'll try tomorrow to use the CU-level package...
> 
> > with Collection_Test_Support;
> > 
> > procedure Jano is
> > 
> >    use Collection_Test_Support;
> > 
> >    type CU_P is access all CU.Collection;
> > 
> >    C : aliased CU.Collection;
> >    CP : CU_P := C'Access;
> > 
> > begin
> > 
> >    declare
> >       It : Containers.Iterator'Class := CU.New_Iterator (CP.all);
> >    begin
> >       null;
> >    end;
> > 
> > end Jano;



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

* Re: Problem with access types using Booch components.
  2003-02-12  9:06     ` Jano
@ 2003-02-12 21:57       ` Simon Wright
  2003-02-13 19:07         ` Jano
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Wright @ 2003-02-12 21:57 UTC (permalink / raw)


Ths will go much quicker if you can send me (by mail would probably be
best, or put it on a web page) the full source that is giving you the
problem. Can you also say what version of the BCs you are using?



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

* Re: Problem with access types using Booch components.
  2003-02-12 21:57       ` Simon Wright
@ 2003-02-13 19:07         ` Jano
  0 siblings, 0 replies; 7+ messages in thread
From: Jano @ 2003-02-13 19:07 UTC (permalink / raw)


En el mensaje <x7vk7g5qhzy.fsf@smaug.pushface.org>, simon@pushface.org 
dice...
> Ths will go much quicker if you can send me (by mail would probably be
> best, or put it on a web page) the full source that is giving you the
> problem. Can you also say what version of the BCs you are using?
> 

Ok, Simon, I'll send you a isolated source with this problem. In respect 
to the version, it is...

<checking>

Well, I stripped the number from the zip, but I downloaded it not long 
ago. Two months or so. Ah, here it is:

--  $RCSfile: bc.ads,v $
--  $Revision: 1.8.2.3 $
--  $Date: 2002/12/24 11:42:44 $
--  $Author: simon $

I'll send it as soon as possible. (Give some days).

-- 
-------------------------
Jano
402450[at]cepsz.unizar.es
-------------------------



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

end of thread, other threads:[~2003-02-13 19:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-11 18:21 Problem with access types using Booch components Jano
2003-02-11 18:49 ` Jano
2003-02-11 20:42 ` Simon Wright
2003-02-11 22:46   ` Jano
2003-02-12  9:06     ` Jano
2003-02-12 21:57       ` Simon Wright
2003-02-13 19:07         ` Jano

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