| 1 |
Copyright 2009 Kevin Ryde |
| 2 |
|
| 3 |
This file is part of constant-defer. |
| 4 |
|
| 5 |
constant-defer is free software; you can redistribute it and/or |
| 6 |
modify it under the terms of the GNU General Public License as |
| 7 |
published by the Free Software Foundation; either version 3, or (at |
| 8 |
your option) any later version. |
| 9 |
|
| 10 |
constant-defer is distributed in the hope that it will be |
| 11 |
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public License along |
| 16 |
with constant-defer. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
constant::defer makes subroutines similar to the builtin constant.pm, |
| 21 |
but with the value calculation deferred until the sub is actually run. |
| 22 |
|
| 23 |
use constant::defer FOO => sub { calculate; |
| 24 |
return $something }; |
| 25 |
|
| 26 |
This is handy for big or slow things only needed sometimes, or where |
| 27 |
at least the pain can be put off the point needed. |
| 28 |
|
| 29 |
Lazy or deferred calculations can be hidden behind a scalar variable |
| 30 |
too. The choice between a sub and a variable is a matter of style or |
| 31 |
personal preference. Both ways have advantages, see the |
| 32 |
constant::defer POD for some notes. |
| 33 |
|
| 34 |
The constant-defer home page is |
| 35 |
|
| 36 |
http://user42.tuxfamily.org/constant-defer/index.html |