On Sun, Mar 23, 2003 at 11:11:54AM +0100, Leopold Toetsch wrote:
> This is a first step in hiding vtable functions - not only: Using these 
> macros also provides more readable source files:
> 
> instead of:
> 
>    PMC* getprop (STRING* key) {
>         return ((PMC *)SELF->data)->vtable->getprop(INTERP,
>               (PMC *)SELF->data, key);
>    }
> 
> this now is:
> 
>    PMC* getprop (STRING* key) {
>       return VTABLE_1(getprop, (PMC*) SELF->data, key);
>    }
> 
> If people are ok with this, next step would be actually using these 
> macros all over the tree.

I think that this is a good idea, as it does appear to simplify the C code
considerably, reduce the scope for errors (and cargo cult programming), and
make it easy to change how the vtables are called in future.

However, I'm aware that perl5 goes a very long way down the "use macros" road;
in many people's opinion too far. I don't think that this is too far,
because

1: It's documented what we are doing here
2: It's only 1 layer of macros (not 4 or more, as perl5 can manage)
3: We don't have the cruft of macros no longer needed but kept for source
   compatibility cluttering up our header files.

There might be some more rules to try to stick to, but they were the 3 that
were obvious to me.

As these are code generated, are we able to conditionally write these out as
inline functions? This would make debugging easer.

Nicholas Clark

Reply via email to