An object method is what is known as two types of pointer. It encapsulates the following information:
- Function Address
- The address of the object or object.
The former is known at compile time, but, as a rule, the latter is not. This is why you usually need to create these things at runtime.
If you can agree that an object is known at compile time, you can declare a typed constant for your record type. For example:
type TMyRecord = record Foo: procedure of object; end; TMyStaticClass = class class procedure Foo; end; class procedure TMyStaticClass.Foo; begin end; const MyRecord: TMyRecord = (Foo: TMyStaticClass.Foo);
Of course, this will only be useful to you if your functions are viable, like class methods, and not instance methods. I just add the code above to illustrate that you can have constant pointers to methods if the object is a compile-time constant.
David heffernan
source share