On Mon, 25 Aug 2003, Joseph Ryan wrote:
> So, I know how to use find_method to get a method from an object;
> but is there any way to dynamically add a method to a class?
> Basically, I want to do something like this:
>
> newclass P2, "Foo"
> new P1, P2
>
> addr I0, _Foo::somemethod
> setmethod P1, "somemethod", I0
> findmethod P0, P1, "somemethod"
> invoke
>
> So, how do I do it? :)
What's supposed to happen is that each class has a backing namespace, and
methods all live in that namespace. Generally objects, no matter what
their HLL class, will be PMCs that have subclassed (at the parrot level)
ParrotObject.
Anyway, for a perl/python/ruby object of class Foo, to add a new method
you'd just add a new sub/method name/PMC binding to the Foo namespace.
Dan