Having read up in the past on Perl5 internals, it seems to be capable of keeping more than one representation of a Scalar active at a time. For instance, if you assigned a number to a variable, treat it like a string, and then again as a number, it does a number->string conversion while still keeping the number around in case you are still going to use it.The way I see this being done is by adding another level of indirection. PerlScalar would implement its polymorphic behavior in the set_* methods, and delegate everything else to its "contained" pmc.
Anyone know if there are plans to do this kind of optimisation? (assuming that it hasn't already!)
Regards,
Nick