On Tue Nov 06 13:09:28 2012, supernovus wrote:
> If you add methods to Any, say using the "augment" feature, or the MOP, the
> methods don't propagate to derived classes.
>
> For example:
>
> use MONKEY_TYPING;
> augment class Any {
> method foo {
> say "hello world";
> }
> }
>
> "blah".foo;
>
> # OUTPUT: «No such method 'hello' for invocant of type 'Str' in block at
> /tmp/_H_vJIBsA8:1»
>
> I tried using Any.add_method() instead of augment, and had the same results.
>
> The augment code above works in Niecza and it is the consensus that it
> should work.
The workaround, btw, is to re-compose the inherited class - this works, e.g:
use MONKEY-TYPING;
augment class Any {
method foo {
say "hello world";
}
}
Str.^compose;
"blah".foo;
--
Will "Coke" Coleda