Skip Menu |

This queue is for tickets about the Dispatch-Declare CPAN distribution.

Report information
The Basics
Id: 24961
Status: resolved
Priority: 0/
Queue: Dispatch-Declare

People
Owner: Nobody in particular
Requestors: dmuey [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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"
Also, "instead of/along with" run() maybe have a funtionally identical dispatch() since it'd be easy to rememeber (Dispatch::Declare has dispatch() and declare()) and since its conceivable that run() could be a built in someday since its so small and generic. Just a thought
From: RLB [...] cpan.org
Looks like good ideas. I will try to work on them this weekend. On Thu Feb 15 00:47:57 2007, DMUEY wrote: Show quoted text
> 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"