[fpc-pascal] How to know if a class implements a method

Matt Emson memsom at interalpha.co.uk
Fri May 18 16:37:21 CEST 2007


> So, at this moment I know that I can:
>
> 1. Use a safe, magic and efficient way, but I need to know if it exists;
> 2. Create a "light" instance using vfooclass.NewInstance method;
> 3. hack the vmt.
>
> Which approach do you use?

I have worked with a bespoke OPF a few years ago. The way we got around this
was to use a multitier approach and literally have the client ask the server
questions in this kind of situation. The server was multithreaded and it
cached information, so it usually didn't have much of an impact. So long as
the network traffic was minimal and only happened once per session (the
reply being cached) it worked well.

We also used a complex inheritance tree with interfaces being passed back
from the server rather than class references. There were also tight rules
about implementing methods. Methods with no implementation were not allowed
in persistently stored objects.

I don't think there's much more really you can do. Other than caching the
RTTI info for each class you use in this way.

HTH




More information about the fpc-pascal mailing list