comp.lang.ada
 help / color / mirror / Atom feed
* Gnat: broken dispatch tables for interface types ?
@ 2012-07-08  3:02 rodakay
  2012-07-08  6:53 ` Dmitry A. Kazakov
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: rodakay @ 2012-07-08  3:02 UTC (permalink / raw)


Hi all,

   Has anyone had any success with interface types ?

   I recently added a function to an interface type. Now when I invoke a function of the interface type, a different function is called. Which function is actually called seems to depend on the order of declaration of the subprograms for the interface type.

   So it seems that the dispatch table for the interface is broken in Gnat ?

   I've tried building with both GPL12 and latest GCC from svn, with the same result.



regards,
Rod.



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-08  3:02 Gnat: broken dispatch tables for interface types ? rodakay
@ 2012-07-08  6:53 ` Dmitry A. Kazakov
  2012-07-08  7:38   ` Jeffrey Carter
  2012-07-08 12:34   ` rodakay
  2012-07-08 17:41 ` Vadim Godunko
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 18+ messages in thread
From: Dmitry A. Kazakov @ 2012-07-08  6:53 UTC (permalink / raw)


On Sat, 7 Jul 2012 20:02:36 -0700 (PDT), rodakay@internode.on.net wrote:

>  Has anyone had any success with interface types ?

Yes, of course. We are heavily using them in our projects.
 
> I recently added a function to an interface type. Now when I invoke a
> function of the interface type, a different function is called.

You should post a small example illustrating the case.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-08  6:53 ` Dmitry A. Kazakov
@ 2012-07-08  7:38   ` Jeffrey Carter
  2012-07-08  8:10     ` Dmitry A. Kazakov
  2012-07-08 12:34   ` rodakay
  1 sibling, 1 reply; 18+ messages in thread
From: Jeffrey Carter @ 2012-07-08  7:38 UTC (permalink / raw)


> On Sat, 7 Jul 2012 20:02:36 -0700 (PDT), rodakay@internode.on.net wrote:
>
>   Has anyone had any success with interface types ?

According to Randy Brukardt, ARG member and editor of the ARM, "Interfaces are 
worthless."

-- 
Jeff Carter
"This school was here before you came,
and it'll be here before you go."
Horse Feathers
48



--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-08  7:38   ` Jeffrey Carter
@ 2012-07-08  8:10     ` Dmitry A. Kazakov
  0 siblings, 0 replies; 18+ messages in thread
From: Dmitry A. Kazakov @ 2012-07-08  8:10 UTC (permalink / raw)


On Sun, 08 Jul 2012 00:38:05 -0700, Jeffrey Carter wrote:

>> On Sat, 7 Jul 2012 20:02:36 -0700 (PDT), rodakay@internode.on.net wrote:
>>
>>   Has anyone had any success with interface types ?
> 
> According to Randy Brukardt, ARG member and editor of the ARM, "Interfaces are 
> worthless."

Yes, if he meant that interface is nothing but abstract tagged null record
plus some silly restrictions.

No, if he meant an ability to codify the interface of a type, multiple
inheritance, interface inheritance, generic programming.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-08  6:53 ` Dmitry A. Kazakov
  2012-07-08  7:38   ` Jeffrey Carter
@ 2012-07-08 12:34   ` rodakay
  2012-07-09  6:53     ` rodakay
  1 sibling, 1 reply; 18+ messages in thread
From: rodakay @ 2012-07-08 12:34 UTC (permalink / raw)
  Cc: mailbox

On Sunday, 8 July 2012 16:53:30 UTC+10, Dmitry A. Kazakov  wrote:
> 
> Yes, of course. We are heavily using them in our projects.

   Thank you Dmitry, that's most encouraging. It did seem unlikely that I could be the only person using interface types :). (Probably, I am the only person using them poorly, though ;) ).


>  
> You should post a small example illustrating the case.

   Yes, indeed. I will try to set up a minimal test case in the next day or so.



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-08  3:02 Gnat: broken dispatch tables for interface types ? rodakay
  2012-07-08  6:53 ` Dmitry A. Kazakov
@ 2012-07-08 17:41 ` Vadim Godunko
  2012-07-09  7:34   ` Rod Kay
  2012-07-08 23:45 ` sbelmont700
  2012-07-10  7:02 ` Rod Kay
  3 siblings, 1 reply; 18+ messages in thread
From: Vadim Godunko @ 2012-07-08 17:41 UTC (permalink / raw)


On Sunday, July 8, 2012 7:02:36 AM UTC+4, (unknown) wrote:
> 
>    So it seems that the dispatch table for the interface is broken in Gnat ?
> 
You can try to do type conversion before call, sometimes it helps to compiler to use correct dispatching table.



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-08  3:02 Gnat: broken dispatch tables for interface types ? rodakay
  2012-07-08  6:53 ` Dmitry A. Kazakov
  2012-07-08 17:41 ` Vadim Godunko
@ 2012-07-08 23:45 ` sbelmont700
  2012-07-10  7:02 ` Rod Kay
  3 siblings, 0 replies; 18+ messages in thread
From: sbelmont700 @ 2012-07-08 23:45 UTC (permalink / raw)


On Saturday, July 7, 2012 11:02:36 PM UTC-4, (unknown) wrote:
>    So it seems that the dispatch table for the interface is broken in Gnat ?

I encountered a similar sounding bug (there is a thread about it somewhere), where GNAT would mangle the dispatch table when allocating (i.e. 'new') limited, controlled, classwide types.  IIRC, the only workaround I found was to allocate it as the concrete type and then convert it to the classwide type manually, but there were still cases in which things were tricky (i.e. functions returning classwide types had to be modified).  Originally it was for GNAT GPL 2011, but it appears as though it remains unfixed in GNAT 2012 (you would think it would be a dealbreaker for GNAT Pro users, but apparently not...)

-sb



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-08 12:34   ` rodakay
@ 2012-07-09  6:53     ` rodakay
  2012-07-09  7:31       ` Dmitry A. Kazakov
  0 siblings, 1 reply; 18+ messages in thread
From: rodakay @ 2012-07-09  6:53 UTC (permalink / raw)
  Cc: mailbox

Here is the 'cut down' code which shows the problem ...

http://www.assembla.com/spaces/openada/documents/bf0foSYzir4y2zacwqjQXA/download/bf0foSYzir4y2zacwqjQXA



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-09  6:53     ` rodakay
@ 2012-07-09  7:31       ` Dmitry A. Kazakov
  2012-07-09  7:46         ` Rod Kay
  2012-07-09  9:37         ` Simon Wright
  0 siblings, 2 replies; 18+ messages in thread
From: Dmitry A. Kazakov @ 2012-07-09  7:31 UTC (permalink / raw)


On Sun, 8 Jul 2012 23:53:42 -0700 (PDT), rodakay@internode.on.net wrote:

> Here is the 'cut down' code which shows the problem ...

I see nothing wrong with dispatching tables. Though the code much too large
and complicated for a small example.

One thing though is that you should not derive new tagged types in bodies.
 
-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-08 17:41 ` Vadim Godunko
@ 2012-07-09  7:34   ` Rod Kay
  0 siblings, 0 replies; 18+ messages in thread
From: Rod Kay @ 2012-07-09  7:34 UTC (permalink / raw)


Thanks Vadim, I'll try it out.



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-09  7:31       ` Dmitry A. Kazakov
@ 2012-07-09  7:46         ` Rod Kay
  2012-07-09  9:37         ` Simon Wright
  1 sibling, 0 replies; 18+ messages in thread
From: Rod Kay @ 2012-07-09  7:46 UTC (permalink / raw)
  Cc: mailbox

> One thing though is that you should not derive new tagged types in bodies.

So it seems. Moving the derivation to a spec and problem disappears. Many thanks ! 



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-09  7:31       ` Dmitry A. Kazakov
  2012-07-09  7:46         ` Rod Kay
@ 2012-07-09  9:37         ` Simon Wright
  2012-07-09  9:49           ` Dmitry A. Kazakov
  1 sibling, 1 reply; 18+ messages in thread
From: Simon Wright @ 2012-07-09  9:37 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> One thing though is that you should not derive new tagged types in
> bodies.

As a matter of interest, why not?



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-09  9:37         ` Simon Wright
@ 2012-07-09  9:49           ` Dmitry A. Kazakov
  2012-07-09 17:32             ` Simon Wright
  2012-07-13 15:58             ` Robert A Duff
  0 siblings, 2 replies; 18+ messages in thread
From: Dmitry A. Kazakov @ 2012-07-09  9:49 UTC (permalink / raw)


On Mon, 09 Jul 2012 10:37:11 +0100, Simon Wright wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
> 
>> One thing though is that you should not derive new tagged types in
>> bodies.
> 
> As a matter of interest, why not?

It does not work well. I never analyzed the RM for the cases when the type
of an object could die before the object itself. But I certainly prefer not
to tease GNAT with these.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-09  9:49           ` Dmitry A. Kazakov
@ 2012-07-09 17:32             ` Simon Wright
  2012-07-09 18:28               ` Dmitry A. Kazakov
  2012-07-13 15:58             ` Robert A Duff
  1 sibling, 1 reply; 18+ messages in thread
From: Simon Wright @ 2012-07-09 17:32 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> On Mon, 09 Jul 2012 10:37:11 +0100, Simon Wright wrote:
>
>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>> 
>>> One thing though is that you should not derive new tagged types in
>>> bodies.
>> 
>> As a matter of interest, why not?
>
> It does not work well. I never analyzed the RM for the cases when the type
> of an object could die before the object itself. But I certainly prefer not
> to tease GNAT with these.

Perhaps you meant in subprogram bodies? I don't see how the life of a
type declared in a library-level package body can die.



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-09 17:32             ` Simon Wright
@ 2012-07-09 18:28               ` Dmitry A. Kazakov
  0 siblings, 0 replies; 18+ messages in thread
From: Dmitry A. Kazakov @ 2012-07-09 18:28 UTC (permalink / raw)


On Mon, 09 Jul 2012 18:32:54 +0100, Simon Wright wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
> 
>> On Mon, 09 Jul 2012 10:37:11 +0100, Simon Wright wrote:
>>
>>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>>> 
>>>> One thing though is that you should not derive new tagged types in
>>>> bodies.
>>> 
>>> As a matter of interest, why not?
>>
>> It does not work well. I never analyzed the RM for the cases when the type
>> of an object could die before the object itself. But I certainly prefer not
>> to tease GNAT with these.
> 
> Perhaps you meant in subprogram bodies? I don't see how the life of a
> type declared in a library-level package body can die.

Upon package finalization and elaboration when things get used prematurely.
It may work or fail in both directions.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-08  3:02 Gnat: broken dispatch tables for interface types ? rodakay
                   ` (2 preceding siblings ...)
  2012-07-08 23:45 ` sbelmont700
@ 2012-07-10  7:02 ` Rod Kay
  2012-07-10 11:09   ` Simon Wright
  3 siblings, 1 reply; 18+ messages in thread
From: Rod Kay @ 2012-07-10  7:02 UTC (permalink / raw)


   I seem to have found the cause of my problem.


   In one case, when an Observer registered itself with a Subject, I'd used the ".all'access" notation to convert from a derived Observer 'access' to the base Observer "access" ...

   Self.Keyboard.register_Observer (Self.all'access, ...);



   When I do the conversion explicitly, all is fine ...

   Self.Keyboard.add (lace.event.Observer.view (Self), ...);



   Thank you Vadim, for the tip.



   Also, it seems I managed to introduce a different error in my (not so) cut-down version of the code (ie deriving types within a body, rather than spec), which Dmitri pointed out. Would two bug reports be in order then ?


   Finally, thanks again to all for the prompt, helpful replies.



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-10  7:02 ` Rod Kay
@ 2012-07-10 11:09   ` Simon Wright
  0 siblings, 0 replies; 18+ messages in thread
From: Simon Wright @ 2012-07-10 11:09 UTC (permalink / raw)


Rod Kay <rodakay@internode.on.net> writes:

> Also, it seems I managed to introduce a different error in my (not
> so) cut-down version of the code (ie deriving types within a body,
> rather than spec), which Dmitri pointed out. Would two bug reports be
> in order then ?

Yes. They may well be caused by different compiler issues.



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

* Re: Gnat: broken dispatch tables for interface types ?
  2012-07-09  9:49           ` Dmitry A. Kazakov
  2012-07-09 17:32             ` Simon Wright
@ 2012-07-13 15:58             ` Robert A Duff
  1 sibling, 0 replies; 18+ messages in thread
From: Robert A Duff @ 2012-07-13 15:58 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> It does not work well. I never analyzed the RM for the cases when the type
> of an object could die before the object itself.

That can't happen.

If you don't believe me, try to construct an example.  If you succeed
then either the language or the compiler is broken.

- Bob



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

end of thread, other threads:[~2012-07-13 15:58 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-08  3:02 Gnat: broken dispatch tables for interface types ? rodakay
2012-07-08  6:53 ` Dmitry A. Kazakov
2012-07-08  7:38   ` Jeffrey Carter
2012-07-08  8:10     ` Dmitry A. Kazakov
2012-07-08 12:34   ` rodakay
2012-07-09  6:53     ` rodakay
2012-07-09  7:31       ` Dmitry A. Kazakov
2012-07-09  7:46         ` Rod Kay
2012-07-09  9:37         ` Simon Wright
2012-07-09  9:49           ` Dmitry A. Kazakov
2012-07-09 17:32             ` Simon Wright
2012-07-09 18:28               ` Dmitry A. Kazakov
2012-07-13 15:58             ` Robert A Duff
2012-07-08 17:41 ` Vadim Godunko
2012-07-09  7:34   ` Rod Kay
2012-07-08 23:45 ` sbelmont700
2012-07-10  7:02 ` Rod Kay
2012-07-10 11:09   ` Simon Wright

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