Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > 5766b5e099e10dc904c497a4750c9f09 > files > 17

postgresql-plparrot-0.05-4.fc18.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
  <title>PL/Parrot - Parrot Virtual Machine in PostgreSQL</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
  <link rel="stylesheet" href="css/project-site.css" type="text/css">
</head>

<body>
<div class="page">
<div class="header">
  <a href="index.html"><img class="logo" src="img/logo.png" alt=""></a>
</div>

<div class="bottom">
<div class="sidebar">
  <ul>
    <li><a href="index.html">Home</a></li>
    <li><a href="docs.html">Documentation</a></li>
    <li><a href="community.html">Community</a></li>
    <li><a href="http://github.com/leto/plparrot/issues">Bugs/Issues</a></li>
    <li><a href="http://wiki.github.com/leto/plparrot/">Wiki</a></li>
  </ul>
</div>

<div class="content">

<h1>Rakudo Perl 6</h1>
<p>
    <a href="http://leto.net">Jonathan "Duke" Leto</a> got <a href="http://rakudo.org/">Rakudo</a> <a
    href="http://perl6.org/">Perl 6</a> working thanks in part to to
efforts by Moritz (moritz++) Lenz, of <a
    href="http://perlgeek.de/">http://perlgeek.de/</a> fame, who
helped make input arguments work correctly.
</p>
<p>
Here is an example stored procedure written in PL/Perl 6, from our test suite:

<pre>
CREATE OR REPLACE FUNCTION test_fibonacci_plperl6(integer) RETURNS int LANGUAGE plperl6 AS $$
{
    [+] (1, 1, *+* ... $^limit)
}
$$;
</pre>
</p>
<p>
The first line is SQL, and everything between the $$ symbols is Perl 6! This stored procedure takes a single integer N and returns the sum of the first N Fibonacci numbers.
</p>
<p> The syntax <b>$^limit</b> is called a "placeholder variable." </p>
You can also specifically name your input arguments like this:
<pre>
CREATE OR REPLACE FUNCTION test_input_3_args(integer, integer, integer)
RETURNS int LANGUAGE plperl6 AS $$
($a, $b, $c) {
    $a - $b + $c
}
$$;
</pre>
This stored procedure is very simple, but shows how you can directly tell PL/Perl6 the "signature" of your procedure. The signature is the ($a,$b,$c), which tells Rakudo Perl 6 that there are three named arguments. The function body (the parts between the { and the } ) simply takes the difference of the first two arguments and adds the third.

</div>
</div>
</div>
</body>

</html>