From 440fa2dcafeddfc333b74e8d838ae060005462a0 Mon Sep 17 00:00:00 2001 From: Sunpoet Po-Chuan Hsieh Date: Sun, 26 Apr 2015 12:28:06 +0000 Subject: [PATCH] - Add p5-constant-defer 6 constant::defer creates a subroutine which on the first call runs given code to calculate its value, and on any subsequent calls just returns that value, like a constant. The value code is discarded once run, allowing it to be garbage collected. Deferring a calculation is good if it might take a lot of work or produce a big result but is only needed sometimes or only well into a program run. If it's never needed then the value code never runs. A deferred constant is generally not inlined or folded (see "Constant Folding" in perlop) since it's not a single scalar value. In the current implementation a deferred constant becomes a plain constant after the first use, so may inline etc in code compiled after that (see "IMPLEMENTATION" below). WWW: http://search.cpan.org/dist/constant-defer/ --- devel/Makefile | 1 + devel/p5-constant-defer/Makefile | 18 ++++++++++++++++++ devel/p5-constant-defer/distinfo | 2 ++ devel/p5-constant-defer/pkg-descr | 15 +++++++++++++++ devel/p5-constant-defer/pkg-plist | 2 ++ 5 files changed, 38 insertions(+) create mode 100644 devel/p5-constant-defer/Makefile create mode 100644 devel/p5-constant-defer/distinfo create mode 100644 devel/p5-constant-defer/pkg-descr create mode 100644 devel/p5-constant-defer/pkg-plist diff --git a/devel/Makefile b/devel/Makefile index c36f87c339da..bde27d6cf750 100644 --- a/devel/Makefile +++ b/devel/Makefile @@ -3239,6 +3239,7 @@ SUBDIR += p5-constant SUBDIR += p5-constant-boolean SUBDIR += p5-constant-def + SUBDIR += p5-constant-defer SUBDIR += p5-constant-lexical SUBDIR += p5-cpan-listchanges SUBDIR += p5-enum diff --git a/devel/p5-constant-defer/Makefile b/devel/p5-constant-defer/Makefile new file mode 100644 index 000000000000..0418a1994828 --- /dev/null +++ b/devel/p5-constant-defer/Makefile @@ -0,0 +1,18 @@ +# Created by: Sunpoet Po-Chuan Hsieh +# $FreeBSD$ + +PORTNAME= constant-defer +PORTVERSION= 6 +CATEGORIES= devel perl5 +MASTER_SITES= CPAN +PKGNAMEPREFIX= p5- + +MAINTAINER= sunpoet@FreeBSD.org +COMMENT= Constant subs with deferred value calculation + +LICENSE= GPLv3 + +USE_PERL5= configure +USES= perl5 + +.include diff --git a/devel/p5-constant-defer/distinfo b/devel/p5-constant-defer/distinfo new file mode 100644 index 000000000000..6de154906f91 --- /dev/null +++ b/devel/p5-constant-defer/distinfo @@ -0,0 +1,2 @@ +SHA256 (constant-defer-6.tar.gz) = 7b21263198ca22686efff3ae987a240be423dd2160afdeb29fe716d032986ffa +SIZE (constant-defer-6.tar.gz) = 43427 diff --git a/devel/p5-constant-defer/pkg-descr b/devel/p5-constant-defer/pkg-descr new file mode 100644 index 000000000000..cf0a623bc9a4 --- /dev/null +++ b/devel/p5-constant-defer/pkg-descr @@ -0,0 +1,15 @@ +constant::defer creates a subroutine which on the first call runs given code to +calculate its value, and on any subsequent calls just returns that value, like a +constant. The value code is discarded once run, allowing it to be garbage +collected. + +Deferring a calculation is good if it might take a lot of work or produce a big +result but is only needed sometimes or only well into a program run. If it's +never needed then the value code never runs. + +A deferred constant is generally not inlined or folded (see "Constant Folding" +in perlop) since it's not a single scalar value. In the current implementation a +deferred constant becomes a plain constant after the first use, so may inline +etc in code compiled after that (see "IMPLEMENTATION" below). + +WWW: http://search.cpan.org/dist/constant-defer/ diff --git a/devel/p5-constant-defer/pkg-plist b/devel/p5-constant-defer/pkg-plist new file mode 100644 index 000000000000..4f62d47ffda0 --- /dev/null +++ b/devel/p5-constant-defer/pkg-plist @@ -0,0 +1,2 @@ +%%SITE_PERL%%/constant/defer.pm +%%PERL5_MAN3%%/constant::defer.3.gz