Permalink
Browse files

Change PL/Perl6 so that the end user can specify the function signatu…

…re directly
  • Loading branch information...
1 parent 1304847 commit 061ed2ad878a97ad8f7b5b7af8509110550aa2a7 @leto committed Aug 17, 2010
Showing with 17 additions and 9 deletions.
  1. +7 −3 plperl6.pir
  2. +10 −6 t/sql/plperl6.sql
View
@@ -22,16 +22,20 @@
.local int nullargs
nullargs = isnull perl6_args
if nullargs goto call_with_empty_args
+ say "calling with args"
$P3 = output(perl6_args)
- call_with_empty_args:
- $P3 = output()
$I0 = isa $P3, "Block"
unless $I0 goto done
# the output of running the function returned a Block,
# such as a pointy block -> $a, $b { }, so let's go ahead
# and execute that
$P3 = $P3(perl6_args)
- done:
+ goto done
+ call_with_empty_args:
+ say "calling with null args"
+ $P3 = output()
+
+ done:
print "code returned: "
_dumper($P3)
say "=============="
View
@@ -42,22 +42,25 @@ CREATE OR REPLACE FUNCTION test_2arguments_plperl6(integer,integer) RETURNS int
$$;
CREATE OR REPLACE FUNCTION test_fibonacci_plperl6(integer) RETURNS int LANGUAGE plperl6 AS $$
-{
+(@_) {
my $limit = @_[0];
[+] (1, 1, *+* ... $limit)
}
$$;
CREATE OR REPLACE FUNCTION test_pointy_fibonacci_plperl6(integer) RETURNS int LANGUAGE plperl6 AS $$
--> $limit {
+($limit) {
[+] (1, 1, *+* ... $limit)
-}(|@_);
+}
$$;
+
CREATE OR REPLACE FUNCTION test_named_pointy(integer, integer, integer) RETURNS int LANGUAGE plperl6 AS $$
--> $a, $b, $c {
- return $a * $b * $c;
-}(|@_);
+{
+ -> $a, $b, $c {
+ return $a * $b * $c;
+ }(|@_);
+}
$$;
CREATE OR REPLACE FUNCTION test_float_plperl6() RETURNS float AS $$
@@ -85,6 +88,7 @@ select is(test_2arguments_plperl6(4,9),2,'PL/Perl sees multiple arguments');
select is(test_named_pointy(10,20,30), 6000, 'Pointy blocks with named parameters work');
+
SELECT language_is_trusted( 'plperl6', 'PL/Perl6 should be trusted' );
-- Finish the tests and clean up.

0 comments on commit 061ed2a

Please sign in to comment.