[fpc-pascal] Java equivalent of Pascal's class reference functionality

Graeme Geldenhuys mailinglists at geldenhuys.co.uk
Thu Jun 9 01:44:39 CEST 2016


On 2016-06-09 00:23, Ryan Gonzalez wrote:
> Not sure about your question exactly, but everything in Java is passed by
> reference

Not quite what I meant. :)  The Object Pascal feature is that my example
code - ExecuteVisitor() - doesn't know at compile time what instance
(any descendant of TVisitor) it is going to instantiate. That
information is only known at runtime.

Usage example:

  ExecuteVisitor(MyData, TShowNameVisitor);
or
  ExecuteVisitor(MyData, TShowEmailVisitor);
etc.

The ExecuteVisitor() will create an instance of the class I specify as
the second argument, and then use it as normal.

Regards,
  Graeme



More information about the fpc-pascal mailing list