Subject: | A few little things for a nice little module! |
An excellent idea, very cool. Glad to see DEFAULT in there :) If you don't mind me bugging
you, here are a few ideas I had and some stuff I noticed:
CODE:
Very nice looking code, BTW a "Boone" to perl you might say :)
Two ideas:
1) in run {}
a) have every call return()
b) provide a default for if they don't specify one
elsif (exists $stash->{'DEFAULT'}) {
$stash->{'DEFAULT'}->();
}
would be
elsif (exists $stash->{'DEFAULT'}) {
return $stash->{'DEFAULT'}->();
}
else {
carp 'Could not run non declared name'; # since you have Carp already...
return;
}
2) new function like "declare_once" that is just like declare() except once its set it can't be
[un]declare[_once]()'ed again. (to keep users from overriding core components unknowingly
for example)
Perhaps near the top of declare(), declare_once(), and undeclare()
carp('Cannot modify declare_once field') && return if exists $once{ uc $key };
in fact it could be doen this way:
sub declare_once($&) {
my $key = shift;
my $code = shift;
carp('Cannot modify declare_once field') && return if exists $once{ uc $key };
declare $key => $code;
$once{ uc $key }++;
return 1;
}
This would need a new lexical hash like my %once;
POD:
a) "BUGS AND LIMITATIONS" needs a blank line after it or else the title include the points :)
(and there' POD to do lists...)
Incidentally I think points 1 and 2 are exactly as it should be :)
b) Your email could be a link if you wanted.
c) "DEFAULT key" I think you meant to be a header (glad you added that)
d) need to update version in "This document describes Dispatch::Declare version 0.0.3"