Skip Menu |

This queue is for tickets about the MooseX-Params-Validate CPAN distribution.

Report information
The Basics
Id: 97085
Status: open
Priority: 0/
Queue: MooseX-Params-Validate

People
Owner: Nobody in particular
Requestors: Bob.Gates [...] netapp.com
Cc:
AdminCc:

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



Subject: not a bug
Date: Wed, 9 Jul 2014 13:45:28 +0000
To: "bug-MooseX-Params-Validate [...] rt.cpan.org" <bug-MooseX-Params-Validate [...] rt.cpan.org>
From: "Gates, Kenneth" <Bob.Gates [...] netapp.com>
When a validation subroutine is called the first time, the parameter spec is prepared and cached to avoid unnecessary regeneration. It uses the fully qualified name of the subroutine (package + subname) as the cache key. In 99.999% of the use cases for this module, that will be the right thing to do. Just a thought, but when using validated_list the default value is seems to be part of the parameter spec so anytime I use a computed default value, ie. my ($state,$timeout,$from) = validated_list( \@_, state =>{ optional=>1, default=>"true" }, timeout=>{ optional=>1, default=>60 }, from =>{ optional=>1, default=>$self->cluster->select_nodes("up")->[0] }, ); I need to turn off caching else it only computes the default the first time the routine is entered and ever after the default does not change. This has caused me and the other members of my team to spend many hours of tracking down subtle bugs because of the caching. It might be nice to be able to globally turn off caching of validation specs since about 50% of our code uses computed defaults and the speed enhancement probably doesn't matter much to us. thx
On Wed Jul 09 09:46:10 2014, Bob.Gates@netapp.com wrote: Show quoted text
> When a validation subroutine is called the first time, the parameter > spec is prepared and cached to avoid unnecessary regeneration. It uses > the fully qualified name of the subroutine (package + subname) as the > cache key. In 99.999% of the use cases for this module, that will be > the right thing to do. > > Just a thought, but when using validated_list the default value is > seems to be part of the parameter spec so anytime I use a computed > default value, ie. > my ($state,$timeout,$from) = validated_list( \@_, > state =>{ optional=>1, default=>"true" }, > timeout=>{ optional=>1, default=>60 }, > from =>{ optional=>1, default=>$self->cluster-
> >select_nodes("up")->[0] },
> ); > I need to turn off caching else it only computes the default the first > time the routine is entered and ever after the default does not > change. This has caused me and the other members of my team to spend > many hours of tracking down subtle bugs because of the caching. It > might be nice to be able to globally turn off caching of validation > specs since about 50% of our code uses computed defaults and the speed > enhancement probably doesn't matter much to us.
This could probably work as an import option. It shouldn't really be global, just package-scoped.