Is it necessary to "use Plugin" in every module where I want to use the plugin's new keywords?
Couldn't we make it so, that if you include the plugin in config.yml, then you get its keywords everywhere where we just "use Dancer"? Please? Code would then be a lot cleaner and shorter.
Hello, 2013/3/4 Punter <punter@punter.gr>:
Couldn't we make it so, that if you include the plugin in config.yml, then you get its keywords everywhere where we just "use Dancer"?
Please?
I don't like that, because you end up with altering the context of a Perl package via a config file. I'm really not a big fan of that. To me, whatever pollutes the namespace should come from the code, this way there is no hidden magic behind the scene, preventing horrible bugs like "where the f** is coming this goo_bar keyword in my namesapce? I don't even load anything in that package!".
Code would then be a lot cleaner and shorter.
As explained, I don't think "cleaner" apply for the resulting code. More implicit, yes, but is that cleaner? -- Alexis
On Mon, 4 Mar 2013 10:04:42 +0100 Alexis Sukrieh <sukria@sukria.net> wrote:
2013/3/4 Punter <punter@punter.gr>:
Couldn't we make it so, that if you include the plugin in config.yml, then you get its keywords everywhere where we just "use Dancer"?
Please?
I don't like that, because you end up with altering the context of a Perl package via a config file.
I'm really not a big fan of that. To me, whatever pollutes the namespace should come from the code, this way there is no hidden magic behind the scene, preventing horrible bugs like "where the f** is coming this goo_bar keyword in my namesapce? I don't even load anything in that package!".
I agree - if code is using any functions/keywords, I expect them to have come directly from one of the modules that the code in question has use'd up top. It would also make pre-req scanning tools such as Dist::Zilla's AutoPrereq plugin miss them.
then you get its keywords everywhere where we just "use Dancer"? You can already make it so yourself with the CPAN modules <http://p3rl.org/Toolkit>, <http://p3rl.org/ToolSet> or <http://p3rl.org/perl5> if you want it. This functionality is not something that Dancer needs to be burdened with.
package MyWebApp; use MySuperDancerWithLotsOfExports; ajax '/check_for_update' => sub { ... }; dance; ---- package MySuperDancerWithLotsOfExports; use parent 'ToolSet'; ToolSet->export( 'Dancer' => undef, 'Dancer::Plugin::Ajax' => undef, ); 1;
participants (4)
-
Alexis Sukrieh -
David Precious -
Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯 -
Punter