[GAP] Ada 2005 object.method doesn't always dispatch
Cyrille Comar
comar at adacore.com
Mon Feb 20 17:43:58 CET 2006
Tullio Vardanega wrote:
If you have the patience of unzipping the project, browse
> through the code (which is basically Martin's and Cyrille's) and
> compile it, you will note an interesting malfunction in the compiler
> (in main.adb), which seems to dislike the object.method syntax
> for the example.
There is indeed one thing that looks fishy to me: I believe the compiler
should accept the object.method notation for a class wide operation and
it doesn't in your case. I'll open an internal ticket on this issue. I
also wanted to comment on your comments:
<<
-- this Operation1 is NON dispatching!
-- procedure Operation1 (This : access Grand_Parent) is abstract;
-- this Operation1 IS dispatching!
procedure Operation1 (This : access Grand_Parent'Class) is abstract;
>>
There is an interesting conflict of language here because strictly
speaking the first Operation1 is dispatching (this is a primitive
operation) whereas the second one is not dispatching (this is a
class-wide operation). That is to say, a call to the first one would be
dispatching if the actual is class-wide (since the operation is abstract
no other actuals are permitted anyway). A call to the second one is
never dispatching. Now, as this thread has shown, the situation is
exactly inversed if you look at the calls in the body of those operations:
This.Operation2;
Will dispatch in the latter case and not in the former. So calls inside
a dispatching operation will have a tendancy not to dispatch whereas
calls inside a classwide non-dispatching operation will have a tendancy
to dispatch naturally.
How do you teach this to students without confusing them? ;-)
More information about the GAP
mailing list