https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78737

--- Comment #23 from janus at gcc dot gnu.org ---
(In reply to Paul Thomas from comment #22)
> If we are to have dynamic dispatch for UD-DTIO, where does it stop?
> Operators, user defined operators?

Not sure I understand your question. Don't we have all of that already? There
are tons of typebound_operator_* and typebound_assignment_* tests in the
testsuite which exercise this kind of stuff AFAICS.

All these things are just special forms of typebound generic bindings, which
always follow the same principle: First you resolve the generic binding to a
specific one (this happens at compile-time, of course). Then you invoke the
specific binding in a polymorphic fashion, i.e. via the vtable (which takes
care of selecting the right procedure at runtime, according to the dynamic
type).

Of course you can even combine typebound operators and DTIO like so:

class(object), allocatable :: a, b, c
[...]
write *, a + b*c

This would involve three typebound generics in one line: the multiplication
operator, the addition operator and the DTIO operator. With a suitable
implementation of the type 'object' (and possibly child classes), this could be
translated into something like

tmp = a->_vptr->add(a, b->_vptr->times(b, c));
tmp->_vptr->write(tmp, ..);

AFAICS all of this is possible and valid in F03, isn't it?

Reply via email to