On 10/09/01 Dan Sugalski wrote:
> >For sanity's sake, I don't suppose you'd consider
> >
> >typedef void* (*vtable_func_t)();
> >
> >to make it
> >
> >vtable_func_t vtable_funcs[VTABLE_SIZE];
>
> I'd be thrilled. Abstract types are A Good Thing. In fact, I'll go make it
> so right now. :)
... and to go a step further in sanity and maintainability, I'd suggest
using a structure with properly typed function pointers instead of an
array:
typedef void (*parrot_pmc_add) (PMC *dest, PMC *a, PMC *b);
typedef void (*parrot_pmc_dispose) (PMC *cookie);
...
typedef struct {
parrot_pmc_add add;
parrot_pmc_dispose dispose;
...
} ParrotVtable;
So the actual code to invoke the method is type checked by the compiler
(and easier to read).
pmc->vtable->add (pmc, pmc_a, pmc_b);
instead of the casts you'd need with the array (or the macro hell to
hide it).
lupus
--
-----------------------------------------------------------------
[EMAIL PROTECTED] debian/rules
[EMAIL PROTECTED] Monkeys do it better