Hacking "method variables"

Markus Gerwinski markus at gerwinski.de
Fri Jun 9 22:35:54 CEST 2006


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.





More information about the Gpc mailing list