I noticed today that Travis was suffering from Extension Angst, now, he didn't say he was suffering from extension angst - that's just how I read it. What is Extension Angst anyway?
Extension Angst occurs when you decide to extend a base class in your package but it feels inappropriate because you're making an arbitrary judgement on the way you believe that base class should behave or act. In Travis's case, he wanted new conditionals for collections. I like his extensions but I also have a touch of extension angst - I can't justify them being part of Smalltalk: The Language.
How could we fix Extension Angst? Well, the angst part comes from the way extensions interact with the rest of the environment. If you load my package, any extensions I've made are now globally available to all packages. This may not be what you want to do at all - in fact, it could be detrimental to the environment. It would be nice if said methods were in fact namespaced.
So hey, why not? ObjectStudio 8 has a neat trick where by if you call a method on a class from an ObjectStudio class and the method is an ObjectStudio specific method that is incompatible with standard VisualWorks behavior - it'll rewrite the selector its sending to be a different one!
We can do the same to extension methods within a package. If you are sending #lastOr: then it could be transformed in to MyPackageNamespace_lastOr: and we could add a default implementation on Object that calls #lastOr: in case you were trying to pickup behavior from another package.
This immediately removes the scoping issue - however it also means that other packages cannot polymorphically use your extensions... but... that was kind of the point. In that case you really need to be able to specify whether a method you're calling is private to your package or not. We could do this with a pragma.
Normally I'd provide code as a proof-of-concept for this sort of blog post, but in this case I didn't feel a strong need to actually see how well this kind of idea would work. I'll leave that exercise up to the reader if they're interested.