I've hit upon quite a major problem with implementing
Perl scalar PMCs. The problem is that the code is just
too damned ugly for words.

Remember that PMCs have a data area which is a void
pointer; I'm connecting that to a structure which has
integer, number and string slots. Those of you familiar
with Perl SVs will know exactly where I'm coming from.

So, for instance, the method to get an integer value
ends up looking like this:

static INTVAL Parrot_scalar_get_integer (struct Parrot_Interp *interpreter, PMC* pmc) {
    if (pmc->flags & PS_INTEGER_OK) {
        return ((struct PerlScalarData *)(pmc->data))->intdata;
    } else if (pmc->flags & PS_NUMBER_OK) {
    pmc->flags |= PS_INTEGER_OK;
    return ((struct PerlScalarData*)(pmc->data))->intdata
        = (INTVAL)(((struct PerlScalarData*)(pmc->data))->numdata);
    ...
}

And that's mild. I could typedef "struct PerlScalarData" to "PSD",
but that wouldn't really help that much. And I could fudge it all
with macros, but that's a Perl 5 thing to do. 

Any suggestions for cleaning up this crap and making it a bit
more maintainable?

-- 
Will your long-winded speeches never end?
What ails you that you keep on arguing?
                -- Job 16:3

Reply via email to