Clear questions and runnable code
get the best and fastest answer
Re^4: use base 'XYZ' and exportingby ihb (Deacon)
|on May 30, 2005 at 00:33 UTC
OK, so forget uplevel and just reimplement what base actually does.
How's that for a contradition of the spirit your main argument for using it? :-) (Having one source for every piece of information.) When base changes, it won't be a base equivalent with just an add-on.
It's a pity base.pm didn't do it right from the start. If you're going to act like "use" then you should do it properly.
People disagree with that "right" behaviour is, but base doesn't pretended to act like use. It can be used for any class, not just classes loaded with use. It's a module to setup inheritance at compile-time (which was important for fields).
This breaks the rule of having 1 source for every piece of information and leads to subtle errors.
In theory I agree with you. I like it the same way I like base's abstraction of loading and @ISA assignment -- I probably should've said that clearer in my reply. I like both semantic and syntactic abstraction. I'm a complete OAOO idiot. But in real life I disagree about this particular example. That's why I said "... what good it really does" (emphasis added). With this you save one occurance of the class name but you likely have at least one more occurance and already have a much harder sync problem; in comparision this is nothing and will probably be taken care of rather automatically. The cost is to confuse the maintenance people and create another hardly needed dependancy.
If this was a patch to base or if it was a standard module it'd be another issue...
See perltoc if you don't know which perldoc to read!