Leopold Toetsch:
# The property 'constant', 'ro' or whatever can only be some kind of
# communication: the HLL is telling the PMC to be read only. We could
now
# have in each set-like vtable:
# 
#    if (we_have_props && !is_bool(prop("ro")) // pseudo code
#       set_the_value ...
#    else
#       throw_exception
# 
#    or we have a different class, that have in the set-like vtable
slots
# just the exception. No penalty for rw classes.

I'm starting to wonder if we shouldn't copy the vtable at construction
time.  That way, we can have our read-only set_* behaviors without
requiring a second class:

        void init(...) {
                SELF->vtable=copy(this_class's_vtable);
                if(is_bool(prop("ro")) {
                        /*
                         * I see no reason we can't provide one
implementation
                         * for all read-onlys--after all, it just needs
to throw 
                         * an exception.
                         */
                        
                        SELF->vtable->set_int=&Parrot_pmc_ro_set_int;
                        SELF->vtable->set_num=&Parrot_pmc_ro_set_num;
        
SELF->vtable->set_string=&Parrot_pmc_ro_set_string;
                        SELF->vtable->set_pmc=&Parrot_pmc_ro_set_pmc;
                        ...
                }
        }

This would also allow for other class-specific vtable customization.
After all, I doubt ro will be the *only* property that's much more
efficiently implemented as a modified vtable...

--Brent Dax <[EMAIL PROTECTED]>
Perl and Parrot hacker
 
"Yeah, and my underwear is flame-retardant--that doesn't mean I'm gonna
set myself on fire to prove it."

Reply via email to