RFC: Unhelpful Defaults

Peter Lobsinger plobsing at gmail.com
Sun Sep 11 19:58:50 UTC 2011

The default PMC, to which most PMCs delegate their unhandled vtables,
makes some odd choices in terms of what functionality it attempts to
provide versus giving up and throwing a "not implemented" exception.
Among the "implemented" vtables are get_pointer, freeze, thaw, visit,
and clone. default's implementation of these isn't particularly
helpful, and IMHO, actively hinders by hiding the fact that many PMCs
do not meaningfully implement these interfaces.

For example, what does Integer.get_pointer() do? If you guessed
something along the lines of "gets a pointer to the INTVAL backing the
PMC", you'd be dead wrong. default helpfully tries to implement the
vtable, but fails miserably, since it lacks sufficient information to
provide the "obvious" choice for the implementation.

I would like to remove these vtables from default (which would cause
pmc2c to default them to throwing "vtable not implemented"
exceptions). This has the very real potential to break code which
makes use of these interfaces on PMCs which don't meaningfully
implement them (for example, we have some tests which call
get_pointer() an values that don't really implement get_pointer). I
would argue that such code already has a subtle bug which is made more
obvious by this change.

For example, removing default.get_pointer() breaks nqp-nom (well
really, the get_addr_i_p opcode nqp uses, whose two senses need
disentangling). I intend to fix the underlying issues to this and any
other reported issues before these changes hit master.

For the purpose of experimentation, I have put the
kill-useless-defaults branch up on github.

More information about the parrot-dev mailing list