On Jun 17, 2010, at 6:51 PM, Kate Yoak wrote:
I finally found a good place to play with inner() and augment. How come inner() is called as a local subroutine instead of an object method? It stands out as a sore thumb and is making me itchy!

Because inner, like super, has, extends, with, requires, augment, before, around, after and override, is a "keyword" and not a method.


I have noticed that inner does not work for roles and, from what I can tell, on purpose. Why is a role an unsuitable application of the inner/augment paradigm? I've been using roles primarily to predefine general functionality with classes being able to customize it, and providing required methods/attributes to enable the role to do its job. Inner/augment fits neatly into this scheme.

In order for augment to work, it requires the superclass to have called inner(). If a role had an augment in it, it would be placing that requirement on the superclass of the classes which consumes it, and that just seemed to couple the role in a very odd way (binding it to the behavior of the superclass of the class). In the end I felt it would add more confusion then it would provide useful methods of re-use.

On the other hand, override and super do work in roles because they place no requirements on the class consuming the role and it it is pretty clear to understand how override and super from a role would work in the applied class, which is take on the context of the class.

I would be interested to see an example of how you would use augment and inner with roles. I could never picture a way to do it in which it didn't seem overly confusing, but I am always willing to admit to my own lack of imagination :)

- Stevan

Reply via email to