Data::Postponed::OnceOnlyData::Postponed::OnceOnly can put off computing a value as long as possible but throw errors if later changes are attempted. | |
Download |
Data::Postponed::OnceOnly Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Joshua ben Jore
- Publisher web site:
- http://search.cpan.org/~jjore/Data-Postponed-0.20/lib/Data/Postponed/OnceOnly.pm
Data::Postponed::OnceOnly Tags
Data::Postponed::OnceOnly Description
Data::Postponed::OnceOnly can put off computing a value as long as possible but throw errors if later changes are attempted. Data::Postponed::OnceOnly can put off computing a value as long as possible but throw errors if later changes are attempted.SYNOPSISExample using postpone() use Data::Postponed 'postpone'; %functions = ( foobar => 'foo' ); $code = "sub " . postpone( $functions{foobar} ) . " { return time }"; $functions{foobar} = "baz"; # Reflects the new name of 'bar' instead of 'foo'. $code isn't # overloaded anymore. print $code; # This line is now an error because $functions{foobar} is readonly. $functions{foobar} = "quux"; # This line isn't reached. print $code;Example using the OO use Data::Postponed; %functions = ( foobar => 'foo' ); $code = "sub " . Data::Postpone::OnceOnly->new( $functions{foobar} ) . " { return time }"; $functions{foobar} = "baz"; # Reflects the new name of 'bar' instead of 'foo'; print $code; # This line is now an error because $functions{foobar} is readonly. $functions{foobar} = "quux"; # This line isn't reached. print $code; Requirements: · Perl
Data::Postponed::OnceOnly Related Software