| Tie-LazyFunction documentation | view source | Contained in the Tie-LazyFunction distribution. |
Tie::LazyFunction - sugar to defer evaluation in a tied scalar
use Tie::LazyFunction;
tie my $lazyvar, Tie::LazyFunction =>
sub {
something we want to defer
},
$arg1var, $arg2var, ... $ #variables which will hold arguments to the sub
;
This short module facilitates binding a coderef to a scalar in such a way that the coderef will be evaluated when the value of the scalar is taken.
When six or fewer arguments are specified after the coderef at tie time, the arguments are not evaluated until they are evaluated within the code. With seven or more arguments, arguments are evaluated at function call time and passed by value.
All arguments are referred to by reference only until FETCH time.
nothing
written in response to discusison of simple lazy variables on perl-5 porters mailing list
It is frustrating that there is no complementary operation to @Refs = \( @Scalars ) aside from @Derefs = map { $$_ } @Refs which fetches the references instead of simply dereferencing them.
Copyright (C) 2005 david nicol davidnico@cpan.org released under your choice of the GNU Public or Artistic licenses
Data::Lazy provides much more than this does
Tie::Function makes function calls look like hash lookups
| Tie-LazyFunction documentation | view source | Contained in the Tie-LazyFunction distribution. |