Sub::DeferredPartial

Sub::DeferredPartial is a deferred evaluation / partial application.
Download

Sub::DeferredPartial Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Steffen Goeldner
  • Publisher web site:
  • http://search.cpan.org/~sgoeldner/Font-FNT-0.02/FNT.pm

Sub::DeferredPartial Tags


Sub::DeferredPartial Description

Sub::DeferredPartial is a deferred evaluation / partial application. Sub::DeferredPartial is a deferred evaluation / partial application.SYNOPSIS use Sub::DeferredPartial 'def'; $S = def sub : P1 P2 P3 { %_=@_; join '', @_{qw(P1 P2 P3)} }; print $S->( P1 => 1, P2 => 2, P3 => 3 )->(); # 123 $A = $S->( P3 => 1 ); # partial application $B = $S->( P3 => 2 ); $C = $A + $B; # deferred evaluation $D = $C->( P2 => 3 ); $E = $D->( P1 => 4 ); print $E->(); # force evaluation: 863 $F = $E - $D; $G = $F->( P1 => 0 ) / 2; print $G->(); # 400 print $G; # ( ( CODE(0x15e3818): P1 => 4, P2 => 3, P3 => 1 + CODE ... $F->(); # Error: Free parameter : P1 $A->( P3 => 7 ); # Error: Bound parameter: P3 $A->( P4 => 7 ); # Error: Wrong parameter: P4An instance of this class behaves like a sub (or, more precisely: subroutine reference), but it supports partial application and the evaluation of operators applied to such function objects is deferred too.That means, evaluation has to be forced explicitly (which makes it easier to add introspection capabilities).Objects that represent deferred (delayed, suspended) expressions are known as suspensions or thunks in various programming circles. Don't confuse with the same terms in the context of threads!Requirements:· Perl Requirements: · Perl


Sub::DeferredPartial Related Software