in reply to Help Name This Module
I like this module, and Ensure is an appropriate name IMO, but Loop::Invariant describes more clearly what the programmer intends to happen. Contract is a close third, while I find Assert unexpected in the sense that the program dosen't die when an assertion fails.
But I have some problems with running your module :
The quick fix to me was a small change to the Ensure::Scalar module as follows :
This fix would have to be repeated for the other modules (or maybe isn't necessary at all with Perl 5.6.1), and I'm not sure if my fix is really a fix and dosen't introduce more errors, as this is the first time I've dabbled with tie :-)sub TIESCALAR { my ($class, $val) = @_; my $ref = [ $val, "setup", "setup" ]; bless $ref, $class; return $ref; } sub FETCH { my $self = shift; my $val = $self->[0]; if (ref($self->[1]) eq 'CODE') { die "[Ensure]\n" unless $self->[1]->(); }; return $val; }
|
---|