develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r33804 - trunk/languages/perl6/src/classes

From:
tene
Date:
December 11, 2008 11:31
Subject:
[svn:parrot] r33804 - trunk/languages/perl6/src/classes
Message ID:
20081211193127.209EFCB9AF@x12.develooper.com
Author: tene
Date: Thu Dec 11 11:31:26 2008
New Revision: 33804

Modified:
   trunk/languages/perl6/src/classes/Code.pir

Log:
[rakudo]: Add .assuming on Code objects for currying.

Modified: trunk/languages/perl6/src/classes/Code.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Code.pir	(original)
+++ trunk/languages/perl6/src/classes/Code.pir	Thu Dec 11 11:31:26 2008
@@ -127,6 +127,35 @@
     .return ($P0)
 .end
 
+=item assumming()
+
+Returns a curried version of self.
+
+=cut
+
+.sub 'assuming' :method :subid('assuming')
+    .param pmc args :slurpy
+    .param pmc named_args :slurpy :named
+    .local pmc curried
+    .lex '@args', args
+    .lex '%args', named_args
+    .lex '$obj', self
+    .const 'Sub' curried = 'assuming_helper'
+    capture_lex curried
+    .return (curried)
+.end
+
+.sub 'assuming_helper' :outer('assuming')
+    .param pmc args :slurpy
+    .param pmc named_args :slurpy :named
+    .local pmc obj, assumed_args, assumed_named_args, result
+    find_lex obj, '$obj'
+    find_lex assumed_args, '@args'
+    find_lex assumed_named_args, '%args'
+    result = obj(assumed_args :flat, args :flat, assumed_named_args :flat :named, named_args :flat :named)
+    .return (result)
+.end
+
 =back
 
 =cut



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About