Prof A Olowofoyeku (The African Chief) wrote:
On 23 Apr 2003 at 18:11, Frank Heckenbach wrote:
[...]
It might not be all that's required for an OOP framework, but I can't see the dynamic methods doing much more than a `case' statement. After all, it's only one integer value ...
Maybe they use other "magic", hidden in the compiler or (I hope) the libraries, independent of dynamic methods.
Be that as it may, simply supporting the syntax would be good enough, and I would be happy with whatever direction you choose to go.
For now I'll just ignore the index. If it ever becomes necessary to use it, one will have to think about how to make it available ...
I may just be about to reveal my ignorance - but can the integer values for dynamic methods not be stored somewhere in the VMT or some other such place?
Sure, storing them is easy. The question is what to do with them afterwards?
And if they can, is there some way of accessing the VMT or its data?
`TypeOf' returns a `PObjectType' pointer which contains the invarying parts of VMTs (see the manual).
It is possible with some dirty tricks (type-casting etc.) to go beyond these fields and access the further contents of the VMT. But I'm not sure we should introduce an "official" feature for it. It wouldn't be too difficult to get the address of some virtual method, but the problem is to store the type (parameter etc.) information -- and much more, checking them on calling.
I.e., when you read the address of a method directly from the VMT, it will just be an untyped pointer, and the compiler can't guess the right type if the method is found at a non-constant place (e.g., by searching for a dynamic index).
So doing this would forfeit all type-checking. This is typical for type-casts, so as said above, I prefer to not make it possible unless one uses type-casts (on the VMT pointer in this case) ...
And again, I don't recommend this for this dispatcher. As I said, I can't see this index doing more than a `case' statement (if it does, then please explain ...), and writing one `case' statement is a small job (one time, and probably mostly automatic), compared to getting mysterious crashes etc. due to the lack of type-checking (and that for possibly every user of the library).
Frank