There is always a problem when one employs too much black magic. But what if you're not actually writing it, but merely useing it?
From what I gather around here, there are a couple of highly-recommended modules to use: Contextual::Return (which is severely simplifying some of my code, so a ++ there) and Exception::Class. Both of these have significant amounts of magic in them, with CR having more when it's trying to fake out caller for intuitive tracebacks, especially when wondering what is going on:
(that should never happen, gotta figure out how to tell Devel::Cover that, but I digress. Probably will just never get 100% and be ok with that.) However, what is giving me a minor amount of trouble is actually the both of these together. Well, not quite. It's testing. When I want to test my exceptions, it simply makes sense (to me, at least) to abuse someone else's shortcuts. So I load in Test::Exception to my test:VALUE { confess "What the... use this as a hashref, bub!" }
Now, remember, My::Module in turn has use Contextual::Return in there as the first use (after strict and warnings). At this point, I get an error message:use Test::More qw(no_plan); # yeah, yeah - I'm developing it. I'll co +unt later. use Test::Exception; BEGIN { use_ok("My::Module"); }
Kind of annoying. After a bit of playing, I've not come up with a better solution than simply moving the Test::Exception load to after the use_ok of my module. Apparently, Test::Exception has some black magic that mucks about with Contextual::Return's black magic. Actually, I expect it's actually Sub::Uplevel, which is dragged in by TE.t/get_set..............Prototype mismatch: sub CORE::GLOBAL::caller (; +$) vs none at /usr/lib64/perl5/site_perl/5.8.8/Contextual/Return.pm l +ine 12.
Though I'm hopeful that much of this deep black magic can go away in perl 6, I have to wonder - will we get back to this level again before perl 7? Is this convenience-creep inevitable that we'll play with things that can come back to nibble at our heels (if not outright bite us in the arse)?
Update: Not that the problem is the main point, but I am running the latest Test::Exception and Sub::Uplevel versions. Mind you, that brings up a parallel question: who to report it to? Is it a problem in C::R? Or in S::U? I suppose I was assuming that this type of dark magic merely gets in the way - if one person does it, it works fine, but when you get competing implementations, that's when things go awry.
Update 2: From looking at S::U's perldoc, it appears there's a conscious effort there to work with C::R. Perhaps it's just C::R's need to work with S::U that is required (for when the loading is in the reverse order). Apparently such bug reports exist, and now we get back into a recent topic about abandoned modules... ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Too much black magic
by xdg (Monsignor) on Jul 05, 2008 at 12:23 UTC | |
|
Re: Too much black magic
by starbolin (Hermit) on Jul 06, 2008 at 01:07 UTC | |
|
Re: Too much black magic
by Anonymous Monk on Jul 05, 2008 at 03:37 UTC |