October 2011 Archives

Announcing namespace::sweep

A question recently appeared on Stack Overflow about using namespace::autoclean in conjunction with operator overloading.

It turns out that you can't, because namespace::autoclean, in addition to cleaning up symbols for imported subs, also cleans up the operator magic installed by overload.pm.

This had been noticed before, but the suggested fix was rejected in favor of implementing the logic to support overload methods in Class::MOP, which namespace::autoclean uses under the hood to figure out the list of allowed methods for a class, and it doesn't look like anyone is interested in doing that right now.

As it happens, I'm working on a distribution right now which uses Moose and does some operator overloading, so namespace::autoclean would be a problem. I decided that there's really no reason a symbol-cleaning pragma should depend on Moose (or the MOP) so I wrote namespace::sweep as a replacement. More on the advantages and disadvantages below.

About Mike Friedman

user-pic Mike Friedman is a professional computer programmer living and working in the New York City area.