Markus Gerwinski wrote:
Peter N Lewis wrote:
OTOH, I would, of course, even prefer to have real, "syntax-approved" method variables that also take into account polymorphy and the fact that methods might be overridden.
I'm afraid I can't understand the point of this, why not just use an indirecting procedure:
Remove the attribute names, and define
Procedure testObjFoo ( obj: pointer ); begin pTestObj(obj)^.foo; end;
That's basically what I've been doing for a couple of years now, and as far as only my own code is affected, I find it a bit annoying, but acceptable. However... well, see below.
No need to rely on the compiler implementation of anything.
Sure there is a negligible drop in efficiency, and you have to write a duplicate for any method you want to use a a procedural variable, but these hardly seem like big problems unless you have very specific requirements that make them big problems...?
The point is: I'm writing an API where I'd like to give the application developer the possibility to pass a method as an initialization parameter to the constructors of some objects. For example to an intermediate wrapper that turns rows of an SQL result set into objects and vice versa.
Can you expand a bit on this example? I'm not sure I can really imagine why this is really necessary? Are the methods that you pass defined in the library and/or the application? Do you need to pass arbitrarily many different methods per object type (so virtual methods won't do)? Do you need it for static and/or virtual methods?
Frank