Dynamic dispatch of class typebound procedures ~ methods
Daniel Kraft
d@domob.eu
Thu Sep 24 22:25:00 GMT 2009
Hi Paul and Janus,
Paul Richard Thomas wrote:
> The next step is to effectively do a select case, using the the class
> object's vindex as a selector, to pick out the procedure to be called.
> I will do this in the next day or two and will extend it to
> subroutines. I have not get my head round typebound operators yet!
that's all very great! Just regarding type-bound operators: As I
already mentioned some times, I believe that you need not really care
about it (and GENERIC); from my understanding, I implemented GENERIC and
type-bound operators "fully", i.e. I do not think you need to take
special care of them (except maybe some small adaptions, but that would
more or less be bug fixes rather than implementing new stuff).
All you should need to handle is correct dispatch of ordinary type-bound
procedures; if that's done, I hope that operators and GENERIC both work
as they should do.
The reason why I think it can "just work" in this case is that GENERIC
(and operators as special GENERIC) is resolved to an ordinary TBP call
(that with matching interface), and this actually already works, no
matter if that TBP call will in turn be dispatched dynamically or (as by
now) just statically.
While it is not known at compile-time which procedure gets actually
called (thus all this runtime type information and vtable business), I
believe for GENERIC it *is* known, to which TBP a call resolves. IIRC,
GENERIC procedures may not be DEFERRED -- and that's just the same point
here, namely because they are dispatched at compile-time to the matching
specific procedure and can not be defined and called dynamically.
I hope I got this right with respect to the standard and have to admit
that I did not check this in detail; but it seems all reasonable to me,
so I hope I did not mess things up.
Anyways, just push forward on dynamic dispatch for TBPs, and if that's
done try out GENERIC and operators. If my prediction is correct, they
should then without further effort already work as expected; if not (or
some errors occur), please come back to me, and I hope that we can still
work it out without many changes...
Thanks for your very, very cool work on OOP! Cheers,
Daniel
--
Done: Arc-Bar-Cav-Ran-Rog-Sam-Tou-Val-Wiz
To go: Hea-Kni-Mon-Pri
More information about the Fortran
mailing list