develooper Front page | perl.perl6.internals | Postings from July 2002

pmc classes discrepency

From:
Tanton Gibbs
Date:
July 19, 2002 22:14
Subject:
pmc classes discrepency
Message ID:
006601c22fac$288ced40$f8ffa8c0@brooklyn
It seems to me that there is a big problem with PMC classes and mutating.
For example, the following is from perlint.pmc

void set_string( PMC* value) {
  CHANGE_TYPE(pmc, PerlString);
  SELF->data = value->data;
}

And the following is from perlstring.cpp
void set_string( PMC* value ) {
  SELF->data = string_copy(INTERP, value->data);
}

It would seem to me that one (perlint) is doing copy on write while the
other is doing an immediate copy even though, to me, they should be doing
the same thing.  However, that aside, the problem, as it appears to me, is
that PerlInt is deciding what to do AFTER IT HAS TURNED INTO A PERLSTRING.
Wouldn't it be better to change the PerlInt to a PerlString and then re-call
the function?  That way, if PerlString was ever updated to perform something
different, PerlInt would be updated too.

If you are worried about the extra function calls, then we could probably
have the pmc processor inline the extra call.  However, the code should only
be in one place.

I don't mind changing this to what I described if everyone agrees.

Thanks!
Tanton




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About