<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<!-- name="generator" content="blosxom/2.0" -->
<channel  rdf:about="http://perlgeek.de/blog-en/">
    <title>Perlgeek.de   </title>
    <link>http://perlgeek.de/blog-en/</link>
    <description>Perl and Programming Blog.</description>
</channel>

  <item rdf:about="http://perlgeek.de/blog-en/perl-6/2013-repl-trick.html">
 <title>The REPL trick</title>
  <link>http://perlgeek.de/blog-en/perl-6/2013-repl-trick.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Wed, Apr 17 21:54:42 2013</pubDate>
    <description>&lt;!-- 1366228482 --&gt;

&lt;p&gt;A recent &lt;a
href=&quot;http://irclog.perlgeek.de/perl6/2013-04-15#i_6706783&quot;&gt;discussion on
IRC&lt;/a&gt; prompted me to share a small but neat trick with you.&lt;/p&gt;

&lt;p&gt;If there are things you want to do quite often in the Rakudo
REPL (the interactive &quot;Read-Evaluate-Print Loop&quot;), it makes sense to create a
shortcut for them. And creating shortcuts for often-used stuff is what
programming languages excel at, so you do it right in Perl module:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synPreProc&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synStatement&quot;&gt;module&lt;/span&gt; REPLHelper&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;synStatement&quot;&gt;sub&lt;/span&gt; p(Mu &lt;span class=&quot;synStatement&quot;&gt;\x&lt;/span&gt;) &lt;span class=&quot;synIdentifier&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;export&lt;/span&gt; {
    &lt;span class=&quot;synStatement&quot;&gt;x.^&lt;/span&gt;mro&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;map&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;*.^&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
}

&lt;/pre&gt;

&lt;p&gt;I have placed mine in &lt;code&gt;$HOME/.perl6/repl&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And then you make sure it's loaded automatically:&lt;/p&gt;

&lt;pre&gt;
$ alias p6repl=&amp;quot;perl6 -I$HOME/.perl6/repl/ -MREPLHelper&amp;quot;
$ p6repl
&amp;gt; p Int
Int Cool Any Mu
&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Now you have a neat one-letter function which tells you the parents of an
object or a type, in method resolution order. And a way to add more shortcuts
when you need them.&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/2013-rakudos-abstract-syntax-tree.html">
 <title>Rakudo's Abstract Syntax Tree</title>
  <link>http://perlgeek.de/blog-en/perl-6/2013-rakudos-abstract-syntax-tree.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Sun, Mar 31 17:22:59 2013</pubDate>
    <description>&lt;!-- 1364743379 --&gt;

&lt;p&gt;After or while a compiler parses a program, the compiler usually translates
the source code into a tree format called &lt;em&gt;Abstract Syntax Tree&lt;/em&gt;, or
&lt;em&gt;AST&lt;/em&gt; for short.&lt;/p&gt;

&lt;p&gt;The optimizer works on this program representation, and then the code
generation stage turns it into a format that the platform underneath it
can understand. Actually I wanted to write about the optimizer, but noticed
that understanding the AST is crucial to understanding the optimizer, so let's
talk about the AST first.&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;http://rakudo.org/&quot;&gt;Rakudo Perl 6 Compiler&lt;/a&gt; uses an AST
format called &lt;em&gt;QAST&lt;/em&gt;. QAST nodes derive from the common superclass
&lt;code&gt;QAST::Node&lt;/code&gt;, which sets up the basic structure of all QAST
classes. Each QAST node has a list of child nodes, possibly a hash map for
unstructured annotations, an attribute (confusingly) named &lt;code&gt;node&lt;/code&gt;
for storing the lower-level parse tree (which is used to extract line numbers
and context), and a bit of extra infrastructure.&lt;/p&gt;

&lt;p&gt;The most important node classes are the following:&lt;/p&gt;

&lt;dl&gt;
    &lt;dt&gt;QAST::Stmts&lt;/dt&gt;
    &lt;dd&gt;A list of statements. Each child of the node is considered a separate
    statement.&lt;/dd&gt;
    &lt;dt&gt;QAST::Op&lt;/dt&gt;
    &lt;dd&gt;A single operation that usually maps to a primitive operation of the
    underlying platform, like adding two integers, or calling a routine.&lt;/dd&gt;
    &lt;dt&gt;QAST::IVal, QAST::NVal, QAST::SVal&lt;/dt&gt;
    &lt;dd&gt;Those hold integer, float (&quot;numeric&quot;) and string constants
    respectively.&lt;/dd&gt;
    &lt;dt&gt;QAST::WVal&lt;/dt&gt;
    &lt;dd&gt;Holds a reference to a more complex object (for example a class) which
    is serialized separately.&lt;/dd&gt;
    &lt;dt&gt;QAST::Block&lt;/dt&gt;
    &lt;dd&gt;A list of statements that introduces a separate lexical scope.&lt;/dd&gt;
    &lt;dt&gt;QAST::Var&lt;/dt&gt;
    &lt;dd&gt;A variable&lt;/dd&gt;
    &lt;dt&gt;QAST::Want&lt;/dt&gt;
    &lt;dd&gt;A node that can evaluate to different child nodes, depending on the
    context it is compiled it.&lt;/dd&gt;
&lt;/dl&gt;

&lt;p&gt;To give you a bit of a feel of how those node types interact, I want to
give a few examples of Perl 6 examples, and what AST they could produce. (It
turns out that Perl 6 is quite a complex language under the hood, and usually
produces a more complicated AST than the obvious one; I'll ignore that for
now, in order to introduce you to the basics.)&lt;/p&gt;

&lt;h2&gt;Ops and Constants&lt;/h2&gt;

&lt;p&gt;The expression &lt;code&gt;23 + 42&lt;/code&gt; could, in the simplest case, produce
this AST:&lt;/p&gt;

&lt;pre&gt;
QAST::Op.new(
    :op('add'),
    QAST::IVal.new(:value(23)),
    QAST::IVal.new(:value(42)),
);
&lt;/pre&gt;

&lt;p&gt;Here an &lt;code&gt;QAST::Op&lt;/code&gt; encodes a primitive operation, an addition of
two numbers. The &lt;code&gt;:op&lt;/code&gt; argument specifies which operation to use.
The child nodes are two constants, both of type &lt;code&gt;QAST::IVal&lt;/code&gt;, which
hold the operands of the low-level operation &lt;code&gt;add&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now the low-level &lt;code&gt;add&lt;/code&gt; operation is not polymorphic, it always
adds two floating-point values, and the result is a floating-point value
again. Since the arguments are integers and not floating point values, they
are automatically converted to float first. That's not the desired semantics for Perl 6; actually the operator
&lt;code&gt;+&lt;/code&gt; is implemented as a subroutine of name
&lt;code&gt;&amp;amp;infix:&amp;lt;+&amp;gt;&lt;/code&gt;, so the real generated code is closer to&lt;/p&gt;

&lt;pre&gt;
QAST::Op.new(
    :op('call'),
    :name('&amp;amp;infix:&amp;lt;+&amp;gt;'),    # name of the subroutine to call
    QAST::IVal.new(:value(23)),
    QAST::IVal.new(:value(42)),
);
&lt;/pre&gt;

&lt;h2&gt;Variables and Blocks&lt;/h2&gt;

&lt;p&gt;Using a variable is as simple as writing
&lt;code&gt;QAST::Var.new(:name('name-of-the-variable'))&lt;/code&gt;, but it must be declared
first. This is done with &lt;code&gt;QAST::Var.new(:name('name-of-the-variable'),
    :decl('var'), :scope('lexical'))&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;But there is a slight caveat: in Perl 6 a variable is always scoped to a
block. So while you can't ordinarily mention a variable prior to its
declaration, there are indirect ways to achieve that (lookup by name, and
&lt;code&gt;eval()&lt;/code&gt;, to name just two).&lt;/p&gt;

&lt;p&gt;So in Rakudo there is a convention to create &lt;code&gt;QAST::Block&lt;/code&gt; nodes
with two &lt;code&gt;QAST::Stmts&lt;/code&gt; children. The first holds all the
declarations, and the second all the actual code. That way all the declaration
always come before the rest of the code.&lt;/p&gt;

&lt;p&gt;So &lt;code&gt;my $x = 42; say $x&lt;/code&gt; compiles to roughly this:&lt;/p&gt;

&lt;pre&gt;
QAST::Block.new(
    QAST::Stmts.new(
        QAST::Var.new(:name('$x'), :decl('var'), :scope('lexical')),
    ),
    QAST::Stmts.new(
        QAST::Op.new(
            :op('p6store'),
            QAST::Var.new(:name('$x')),
            QAST::IVal.new(:value(42)),
        ),
        QAST::Op.new(
            :op('call'),
            :name('&amp;amp;say'),
            QAST::Var.new(:name('$x')),
        ),
    ),
);
&lt;/pre&gt;

&lt;h2&gt;Polymorphism and QAST::Want&lt;/h2&gt;

&lt;p&gt;Perl 6 distinguishes between native types and reference types. Native types
are closer to the machine, and their type name is always lower case in Perl
6.&lt;/p&gt;

&lt;p&gt;Integer literals are polymorphic in that they can be either a native
&lt;code&gt;int&lt;/code&gt; or a &quot;boxed&quot; reference type &lt;code&gt;Int&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To model this in the AST, &lt;code&gt;QAST::Want&lt;/code&gt; nodes can contain
multiple child nodes. The compile-time context decides which of those is
acutally used.&lt;/p&gt;

&lt;p&gt;So the integer literal &lt;code&gt;42&lt;/code&gt; actually produces not just a simple
&lt;code&gt;QAST::IVal&lt;/code&gt; node but rather this:&lt;/p&gt;

&lt;pre&gt;
QAST::Want.new(
    QAST::WVal(Int.new(42)),
    'Ii',
    QAST::Ival(42),
)
&lt;/pre&gt;

&lt;p&gt;(Note that &lt;code&gt;Int.new(42)&lt;/code&gt; is just a nice notation to indicate a
boxed integer object; it doesn't quite work like this in the code that
translate Perl 6 source code into ASTs).&lt;/p&gt;

&lt;p&gt;The first child of a &lt;code&gt;QAST::Want&lt;/code&gt; node is the one used by
default, if no other alternative matches. The comes a list where the elements
with odd indexes  are format specifications (here &lt;code&gt;Ii&lt;/code&gt; for
integers) and the elements at even-side indexes are the AST to use in that
case.&lt;/p&gt;

&lt;p&gt;An interesting format specification is &lt;code&gt;'v'&lt;/code&gt; for void context,
which is always chosen when the return value from the current expression isn't
used at all. In Perl 6 this is used to eagerly evaluate lazy lists that are
used in void context, and for several optimizations.&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/2013-pattern-matching.html">
 <title>Pattern Matching and Unpacking</title>
  <link>http://perlgeek.de/blog-en/perl-6/2013-pattern-matching.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Tue, Feb 12 21:49:13 2013</pubDate>
    <description>&lt;!-- 1360702153 --&gt;
&lt;p&gt;When talking about &lt;em&gt;pattern matching&lt;/em&gt; in the context of Perl 6,
people usually think about regex or grammars. Those are indeed very powerful
tools for pattern matching, but not the only one.&lt;/p&gt;

&lt;p&gt;Another powerful tool for pattern matching and for unpacking data
structures uses signatures.&lt;/p&gt;

&lt;p&gt;Signatures are &quot;just&quot; argument lists:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synStatement&quot;&gt;sub&lt;/span&gt; repeat(&lt;span class=&quot;synType&quot;&gt;Str&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$s&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt; Int &lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;$count&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt; &lt;/span&gt;{
    &lt;span class=&quot;synComment&quot;&gt;#     ^^^^^^^^^^^^^^^^^^^^  the signature&lt;/span&gt;
    &lt;span class=&quot;synComment&quot;&gt;# $s and $count are the parameters&lt;/span&gt;
    &lt;span class=&quot;synSpecial&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$s&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$count&lt;/span&gt;
}
&lt;/pre&gt;

&lt;p&gt;Nearly all modern programming languages have signatures, so you might say:
nothing special, move along. But there are two features that make them more useful
than signatures in other languages.&lt;/p&gt;

&lt;p&gt;The first is &lt;em&gt;multi dispatch&lt;/em&gt;, which allows you to write several
routines with the name, but with different signatures. While extremely
powerful and helpful, I don't want to dwell on them. Look at Chapter 6 of
the &lt;a href=&quot;https://github.com/downloads/perl6/book/2012.05.23.a4.pdf&quot;&gt;&quot;Using
Perl 6&quot; book&lt;/a&gt; for more details.&lt;/p&gt;

&lt;p&gt;The second feature is &lt;em&gt;sub-signatures&lt;/em&gt;. It allows you to write a
signature for a sigle parameter.&lt;/p&gt;

&lt;p&gt;Which sounds pretty boring at first, but for example it
allows you to do declarative validation of data structures. Perl 6 has no
built-in type for an array where each slot must be of a specific but different
type. But you can still check for that in a sub-signature&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synStatement&quot;&gt;sub&lt;/span&gt; f(&lt;span class=&quot;synIdentifier&quot;&gt;@array&lt;/span&gt; [&lt;span class=&quot;synType&quot;&gt;Int&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synType&quot;&gt;Str&lt;/span&gt;]) {
    &lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@array&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;join&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;, &lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
}
f [&lt;span class=&quot;synConstant&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;]&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;      &lt;span class=&quot;synComment&quot;&gt;# 42, str&lt;/span&gt;
f [&lt;span class=&quot;synConstant&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;23&lt;/span&gt;]&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;         &lt;span class=&quot;synComment&quot;&gt;# Nominal type check failed for parameter '';&lt;/span&gt;
                    &lt;span class=&quot;synComment&quot;&gt;# expected Str but got Int instead in sub-signature&lt;/span&gt;
                    &lt;span class=&quot;synComment&quot;&gt;# of parameter @array&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;Here we have a parameter called &lt;code&gt;@array&lt;/code&gt;, and it is followed by
a square brackets, which introduce a sub-signature for an array. When calling
the function, the array is checked against the signature &lt;code&gt;(Int,
Str)&lt;/code&gt;, and so if the array doesn't contain of exactly one Int and one
Str in this order, a type error is thrown.&lt;/p&gt;

&lt;p&gt;The same mechanism can be used not only for validation, but also for
&lt;em&gt;unpacking&lt;/em&gt;, which means extracting some parts of the data structure.
This simply works by using variables in the inner signature:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synStatement&quot;&gt;sub&lt;/span&gt; head(&lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt;@ [&lt;span class=&quot;synIdentifier&quot;&gt;$head&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt;@]) {
    &lt;span class=&quot;synIdentifier&quot;&gt;$head&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
}
&lt;span class=&quot;synStatement&quot;&gt;sub&lt;/span&gt; tail(&lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt;@ [&lt;span class=&quot;synIdentifier&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;@tail&lt;/span&gt;]) {
    &lt;span class=&quot;synIdentifier&quot;&gt;@tail&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
}
&lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; head &lt;span class=&quot;synSpecial&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;a b c &lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;      &lt;span class=&quot;synComment&quot;&gt;# a&lt;/span&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; tail &lt;span class=&quot;synSpecial&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;a b c &lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;      &lt;span class=&quot;synComment&quot;&gt;# b c&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;Here the outer parameter is anonymous (the &lt;code&gt;@&lt;/code&gt;), though it's
entirely possible to use variables for both the inner and the outer
parameter.&lt;/p&gt;

&lt;p&gt;The anonymous parameter can even be omitted, and you can write &lt;code&gt;sub
tail( [$, *@tail] )&lt;/code&gt; directly.&lt;/p&gt;

&lt;p&gt;Sub-signatures are not limited to arrays. For working on arbitrary objects,
you surround them with parenthesis instead of brackets, and use named
parameters inside:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synStatement&quot;&gt;multi&lt;/span&gt; key-type ($ (Numeric &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;$key&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;*%&lt;/span&gt;)) { &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt; }
&lt;span class=&quot;synStatement&quot;&gt;multi&lt;/span&gt; key-type ($ (&lt;span class=&quot;synType&quot;&gt;Str&lt;/span&gt;     &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;$key&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;*%&lt;/span&gt;)) { &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt; }
&lt;span class=&quot;synStatement&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;synConstant&quot;&gt;42&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;b&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;42&lt;/span&gt;) &lt;span class=&quot;synStatement&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$pair&lt;/span&gt; {
    &lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; key-type &lt;span class=&quot;synIdentifier&quot;&gt;$pair&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
}
&lt;span class=&quot;synComment&quot;&gt;# Output:&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;# Number&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;# String&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;This works because the &lt;code&gt;=&amp;gt;&lt;/code&gt; constructs a &lt;a
href=&quot;http://doc.perl6.org/type/Pair&quot;&gt;Pair&lt;/a&gt;, which has a
&lt;code&gt;key&lt;/code&gt; and a &lt;code&gt;value&lt;/code&gt; attribute. The named parameter
&lt;code&gt;:$key&lt;/code&gt; in the sub-signature extracts the attribute
&lt;code&gt;key&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can build quite impressive things with this feature, for example &lt;a
href=&quot;http://rosettacode.org/wiki/Pattern_matching#Perl_6&quot;&gt;red-black tree
balancing based on multi dispatch and signature unpacking&lt;/a&gt;. (&lt;a
href=&quot;http://blogs.perl.org/users/ovid/2013/02/red-black-trees-in-perl-6-explained.html&quot;&gt;More verbose explanation of the code&lt;/a&gt;.) Most use
cases aren't this impressive, but still it is very useful to have
occasionally. Like for &lt;a
href=&quot;https://gist.github.com/masak/ca5a82ae76951cc387cc&quot;&gt;this small
evaluator.&lt;/a&gt;&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/2012-quo-vadis-perl.html">
 <title>Quo Vadis Perl?</title>
  <link>http://perlgeek.de/blog-en/perl-6/2012-quo-vadis-perl.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Sun, Aug 19 14:30:37 2012</pubDate>
    <description>&lt;!-- 1345379437 --&gt;

&lt;p&gt;The last two days we had a gathering in town named Perl (yes, a place with
that name exists). It's a lovely little town next to the borders to France and
Luxembourg, and our meeting was titled &quot;Perl Reunification Summit&quot;.&lt;/p&gt;

&lt;p&gt;Sadly I only managed to arrive in Perl on Friday late in the night, so I
missed the first day. Still it was totally worth it.&lt;/p&gt;

&lt;p&gt;We tried to answer the question of how to make the Perl 5 and the Perl 6
community converge on a social level. While we haven't found the one true
answer to that, we did find that discussing the future together, both on a
technical and on a social level, already brought us closer together.&lt;/p&gt;

&lt;p&gt;It was quite a touching moment when Merijn &quot;Tux&quot; Brand explained that he
was skeptic of Perl 6 before the summit, and now sees it as the future.&lt;/p&gt;

&lt;p&gt;We also concluded that copying API design is a good way to converge on a
technical level. For example Perl 6's IO subsystem is in desperate need of
a cohesive design. However none of the Perl 6 specification and the Rakudo
development team has much experience in that area, and copying from
successful Perl 5 modules is a viable approach here. Path::Class and IO::All
(excluding the crazy parts) were mentioned as targets worth looking at.&lt;/p&gt;

&lt;p&gt;There is now also an IRC channel to continue our discussions -- join
&lt;code&gt;#p6p5&lt;/code&gt; on irc.perl.org if you are interested.&lt;/p&gt;

&lt;p&gt;We also discussed ways to bring parallel programming to both perls. I
missed most of the discussion, but did hear that one approach is to make
easier to send other processes some serialized objects, and thus distribute
work among several cores.&lt;/p&gt;

&lt;p&gt;Patrick Michaud gave a short ad-hoc presentation on implicit parallelism in
Perl 6. There are several constructs where the language allows parallel
execution, for example for &lt;a
href=&quot;http://perl6advent.wordpress.com/2009/12/06/day-6-going-into-hyperspace/&quot;&gt;Hyper
operators&lt;/a&gt;, &lt;a href=&quot;http://doc.perl6.org/type/Junction&quot;&gt;junctions&lt;/a&gt; and
feeds (think of feeds as UNIX pipes, but ones that allow passing of objects
and not just strings). Rakudo doesn't implement any of them in parallel right
now, because the Parrot Virtual Machine does not provide the necessary
primitives yet.&lt;/p&gt;

&lt;p&gt;Besides the &quot;official&quot; program, everybody used the time in meat space
to discuss their favorite projects with everybody else. For example I took
some time to discuss the future of &lt;a
href=&quot;http://doc.perl6.org/&quot;&gt;doc.perl6.org&lt;/a&gt; with Patrick and Gabor Szabgab,
and the relation to &lt;a href=&quot;http://perl6maven.com/&quot;&gt;perl6maven&lt;/a&gt; with the
latter. The Rakudo team (which was nearly completely present) also discussed
several topics, and I was happy to talk about the relation between Rakudo and
Parrot with Reini Urban.&lt;/p&gt;

&lt;p&gt;Prior to the summit my expectations were quite vague. That's why it's hard
for me to tell if we achieved what we and the organizers
wanted. Time will tell, and we want to summarize the result in six to nine
months. But I am certain that many participants have changed some of their
views in positive ways, and left the summit with a warm, fuzzy feeling.&lt;/p&gt;

&lt;p&gt;I am very grateful to have been invited to such a meeting, and enjoyed it
greatly. Our host and organizers, Liz and Wendy, took care of all of our
needs  -- travel, food, drinks, space, wifi, accommodation, more food,
entertainment, food for thought, you name it. Thank you very much!&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Update:&lt;/b&gt; Follow the &lt;a
href=&quot;https://twitter.com/#!/search/?q=%23p6p5&quot;&gt;#p6p5&lt;/a&gt; hash tag on twitter
if you want to read more, I'm sure other participants will blog too.&lt;/p&gt;

&lt;p&gt;Other blogs posts on this topic: &lt;a
href=&quot;http://mdk.per.ly/2012/08/20/prs2012-perl5-perl6-reunification-summit/&quot;&gt;&lt;i&gt;PRS2012 – Perl5-Perl6 Reunification Summit&lt;/i&gt; by mdk&lt;/a&gt; and
&lt;a href=&quot;http://blogs.perl.org/users/theorbtwo/2012/08/post-yapc.html&quot;&gt;&lt;i&gt;post-yapc&lt;/i&gt; by theorbtwo&lt;/a&gt;&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/2012-stop-the-rewrites.html">
 <title>Stop The Rewrites!</title>
  <link>http://perlgeek.de/blog-en/perl-6/2012-stop-the-rewrites.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Tue, Jul 17 18:52:04 2012</pubDate>
    <description>&lt;!-- 1342543924 --&gt;
&lt;p&gt;What follows is a rant. If you're not in the mood to read a rant right now,
please stop and come back in an hour or two.&lt;/p&gt;

&lt;p&gt;The Internet is full of people who know better than you how to manage
your open source project, even if they only know some bits and pieces about
it. News at 11.&lt;/p&gt;

&lt;p&gt;But there is one particular instance of that advice that I hear often
applied to &lt;a href=&quot;http://rakudo.org/&quot;&gt;Rakudo Perl 6&lt;/a&gt;: &lt;a
href=&quot;http://www.perlmonks.org/?node_id=982243&quot;&gt;Stop the rewrites&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To be honest, I can fully understand the sentiment behind that advice.
People see that it has taken us several years to get where we are now, and in
their opinion, that's too long. And now we shouldn't waste our time with
rewrites, but get the darn thing running already!&lt;/p&gt;

&lt;p&gt;But Software development simply doesn't work that way. Especially not if
your target is moving, as is Perl 6. (Ok, Perl 6 isn't moving that much
anymore, but there are still areas we don't understand very well, so our
current understanding of Perl 6 is a moving target).&lt;/p&gt;

&lt;p&gt;At some point or another, you realize that with your current design, you
can only pile workaround on top of workaround, and hope that the whole thing
never collapses.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/blog/jenga.jpg&quot; width=&quot;522&quot; height=&quot;1024&quot; alt=&quot;Picture of
a Jenga tower&quot; /&gt;&lt;br /&gt;
&lt;em&gt;Image courtesy of &lt;a
href=&quot;http://www.flickr.com/photos/sermoa/2353990935/&quot;&gt;sermoa&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Those people who spread the good advice to never do any major rewrites
again, they never address what you &lt;b&gt;should&lt;/b&gt; do when you face such a
situation. Build the tower of workarounds even higher, and pray to Cthulhu
that you can build it robust enough to support a whole stack of third-party
modules?&lt;/p&gt;

&lt;p&gt;Curiously this piece of advice occasionally comes from people who otherwise
know a thing or two about software development methodology.&lt;/p&gt;

&lt;p&gt;I should also add that since the famous &quot;nom&quot; switchover, which admittedly
caused lots of fallout, we had three major rewrites of subsystems
(longest-token matching of alternative, bounded serialization and qbootstrap),
All three of which caused no new test failures, and two of which caused no
fallout from the module ecosystem at all. In return, we have much faster
startup (factor 3 to 4 faster) and a much more correct regex engine.&lt;/p&gt;



</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/2012-doc-perl6-org-and-p6doc.html">
 <title>doc.perl6.org and p6doc</title>
  <link>http://perlgeek.de/blog-en/perl-6/2012-doc-perl6-org-and-p6doc.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Wed, Jul  4 10:11:59 2012</pubDate>
    <description>&lt;!-- 1341389519 --&gt;

&lt;h2&gt;Background&lt;/h2&gt;

&lt;p&gt;Earlier this year I tried to assess the readiness of the Perl 6
language, compilers, modules, documentation and so on. While I never
got around to publish my findings, one thing was painfully obvious:
there is a huge gap in the area of documentation.&lt;/p&gt;

&lt;p&gt;There are quite a few resources, but none of them comprehensive
(most comprehensive are the
&lt;a href=&quot;http://perlcabal.org/syn/&quot;&gt;synopsis&lt;/a&gt;, but they are not meant
for the end user), and no single location we can point people to.&lt;/p&gt;

&lt;h2&gt;Announcement&lt;/h2&gt;

&lt;p&gt;So, in the spirit of &lt;a href=&quot;http://xkcd.com/927/&quot;&gt;xkcd&lt;/a&gt;, I
present yet another incomplete documentation project:
&lt;a href=&quot;http://doc.perl6.org/&quot;&gt;doc.perl6.org&lt;/a&gt; and &lt;code&gt;p6doc&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The idea is to take the same approach as perldoc for Perl 5: create
user-level documentation in Pod format (here the Perl 6 Pod), and make it
available both on a website and via a command line tool. The source
(documentation, command line tool, HTML generator) lives at &lt;a
href=&quot;https://github.com/perl6/doc/&quot;&gt;https://github.com/perl6/doc/&lt;/a&gt;.
The website is &lt;a href=&quot;http://doc.perl6.org/&quot;&gt;doc.perl6.org&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Oh, and the last Rakudo Star release (2012.06) already shipped
p6doc.&lt;/p&gt;

&lt;h2&gt;Status and Plans&lt;/h2&gt;

&lt;p&gt;Documentation, website and command line tool are all in very early
stages of development.&lt;/p&gt;

&lt;p&gt;In the future, I want both
&lt;code&gt;p6doc SOMETHING&lt;/code&gt; and
&lt;code&gt;http://doc.perl6.org/SOMETHING&lt;/code&gt; to either document or link to
documentation of SOMETHING, be it a built-in variable, an operator, a
type name, routine name, phaser, constant or... all the other possible
constructs that occur in Perl 6. URLs and command line arguments
specific to each type of construct will also be available
(&lt;code&gt;/type/SOMETHING&lt;/code&gt; URLs already work).&lt;/p&gt;

&lt;p&gt;Finally I want some way to get a &quot;full&quot; view of a type, ie providing
all methods from superclasses and roles too.&lt;/p&gt;

&lt;h2&gt;Help Wanted&lt;/h2&gt;

&lt;p&gt;All of that is going to be a lot of work, though the most work will
be to write the documentation. You too can help! You can write new
documentation, gather and incorporate already existing documentation
with compatible licenses (for example synopsis, perl 6 advent calendar,
examples from rosettacode), add more examples, proof-read the
documentation or improve the HTML generation or the command line tool.&lt;/p&gt;

&lt;p&gt;If you have any questions about contributing, feel free to ask in &lt;a
href=&quot;http://perl6.org/community/irc&quot;&gt;#perl6&lt;/a&gt;. Of course you can
also;
create pull requests right away :-).&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/2012-news-in-rakudo-2012-06-release.html">
 <title>News in the Rakudo 2012.06 release</title>
  <link>http://perlgeek.de/blog-en/perl-6/2012-news-in-rakudo-2012-06-release.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Fri, Jun 22 11:00:00 2012</pubDate>
    <description>&lt;!-- 1340355600 --&gt;

&lt;p&gt;Rakudo development continues to progress nicely, and so there are a few
changes in this month's release worth explaining.&lt;/p&gt;

&lt;h2&gt;Longest Token Matching, List Iteration&lt;/h2&gt;

&lt;p&gt;The largest chunk of development effort went into &lt;a
href=&quot;http://6guts.wordpress.com/2012/06/07/ltm-for-alternations/&quot;&gt;Longest-Token
Matching for alternations in Regexes&lt;/a&gt;, about which Jonathan already
blogged. Another significant piece was Patrick's refactor of list iteration.
You probably won't notice much of that, except that for-loops are now a bit
faster (maybe 10%), and laziness works more reliably in a couple of cases.&lt;/p&gt;

&lt;h2&gt;String to Number Conversion&lt;/h2&gt;

&lt;p&gt;String to number conversion is now stricter than before. Previously an
expression like &lt;code&gt;+&quot;foo&quot;&lt;/code&gt; would simply return 0. Now it fails, ie
returns an unthrown exception. If you treat that unthrown exception like a
normal value, it blows up with a helpful error message, saying that the
conversion to a number has failed. If that's not what you want, you can still
write &lt;code&gt;+$str // 0&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;&lt;code&gt;require&lt;/code&gt; With Argument Lists&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;require&lt;/code&gt; now supports argument lists, and that needs a bit more
explaining. In Perl 6 routines are by default only looked up in lexical
scopes, and lexical scopes are immutable at run time. So, when loading a
module at run time, how do you make functions available to the code that loads
the module? Well, you determine at compile time which symbols you want to
import, and then do the actual importing at run time:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synPreProc&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synPreProc&quot;&gt;require&lt;/span&gt; Test &lt;span class=&quot;synSpecial&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;&amp;amp;plan &amp;amp;ok &amp;amp;is&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#            ^^^^^^^^^^^^^^^ evaluated at compile time,&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#                            declares symbols &amp;amp;plan, &amp;amp;ok and &amp;amp;is&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#       ^^^                  loaded at run time&lt;/span&gt;
&lt;/pre&gt;

&lt;h2&gt;Module Load Debugging&lt;/h2&gt;

&lt;p&gt;Rakudo had some trouble when modules were precompiled, but its
dependencies were not. This happens more often than it sounds, because Rakudo
checks timestamps of the involved files, and loads the source version if it is
newer than the compiled file. Since many file operations (including simple
copying) change the time stamp, that could happen very easily.&lt;/p&gt;

&lt;p&gt;To make debugging of such errors easier, you can set the
&lt;code&gt;RAKUDO_MODULE_DEBUG&lt;/code&gt; environment variable to 1 (or any positive
number; currently there is only one debugging level, in the future higher
numbers might lead to more output).&lt;/p&gt;

&lt;pre&gt;
$ RAKUDO_MODULE_DEBUG=1 ./perl6 -Ilib t/spec/S11-modules/require.t
MODULE_DEBUG: loading blib/Perl6/BOOTSTRAP.pbc
MODULE_DEBUG: done loading blib/Perl6/BOOTSTRAP.pbc
MODULE_DEBUG: loading lib/Test.pir
MODULE_DEBUG: done loading lib/Test.pir
1..5
MODULE_DEBUG: loading t/spec/packages/Fancy/Utilities.pm
MODULE_DEBUG: done loading t/spec/packages/Fancy/Utilities.pm
ok 1 - can load Fancy::Utilities at run time
ok 2 - can call our-sub from required module
MODULE_DEBUG: loading t/spec/packages/A.pm
MODULE_DEBUG: loading t/spec/packages/B.pm
MODULE_DEBUG: loading t/spec/packages/B/Grammar.pm
MODULE_DEBUG: done loading t/spec/packages/B/Grammar.pm
MODULE_DEBUG: done loading t/spec/packages/B.pm
MODULE_DEBUG: done loading t/spec/packages/A.pm
ok 3 - can require with variable name
ok 4 - can call subroutines in a module by name
ok 5 - require with import list
&lt;/pre&gt;

&lt;h2&gt;Module Loading Traces in Compile-Time Errors&lt;/h2&gt;

&lt;p&gt;If module myA loads module myB, and myB dies during compilation, you now
get a backtrace which indicates through which path the erroneous module was
loaded:&lt;/p&gt;

&lt;pre&gt;
$ ./perl6 -Ilib -e 'use myA'
===SORRY!===
Placeholder variable $^x may not be used here because the surrounding block
takes no signature
at lib/myB.pm:1
  from module myA (lib/myA.pm:3)
  from -e:1
&lt;/pre&gt;

&lt;h2&gt;Improved autovivification&lt;/h2&gt;

&lt;p&gt;Perl allows you to treat not-yet-existing array and hash elements as arrays
or hashes, and automatically creates those elements for you. This is called
autovivification.&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synSpecial&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;%h&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;%h&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;push&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;synComment&quot;&gt;# worked in the previous release too&lt;/span&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;push&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;%h&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;synComment&quot;&gt;# newly works in the 2012.06&lt;/span&gt;
&lt;/pre&gt;



</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/2012-localizing-exceptions.html">
 <title>Localization for Exception Messages</title>
  <link>http://perlgeek.de/blog-en/perl-6/2012-localizing-exceptions.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Thu, Jun  7 18:07:18 2012</pubDate>
    <description>&lt;!-- 1339085238 --&gt;

&lt;p&gt;Ok, my previous blog post wasn't &lt;a
href=&quot;http://perlgeek.de/blog-en/perl-6/2012-grant-report-final-status-update.html&quot;&gt;quite
as final as I thought.&lt;/a&gt;. My &lt;a
href=&quot;http://news.perlfoundation.org/2011/02/hague-grant-application-struct.html&quot;&gt;exceptions
grant&lt;/a&gt; said that the design should make it easy to enable localization and
internationalization hooks. I want to discuss some possible approaches and
thereby demonstrate that the design is flexible enough as it is.&lt;/p&gt;

&lt;p&gt;At this point I'd like to mention that much of the flexibility comes from
either Perl 6 itself, or from the separation of stringifying and exception and
generating the actual error message.&lt;/p&gt;

&lt;h2&gt;Mixins: the sledgehammer&lt;/h2&gt;
       
&lt;p&gt;One can always override a method in an object by mixing in a role which
contains the method on question. When the user requests error messages in a
different language, one can replace method &lt;code&gt;Str&lt;/code&gt; or method
&lt;code&gt;message&lt;/code&gt; with one that generates the error message in a different
language.&lt;/p&gt;

&lt;p&gt;Where should that happen? The code throws exceptions is fairly scattered
over the code base, but there is a central piece of code in Rakudo that
turns Parrot-level exceptions into Perl 6 level exceptions. That would be an
obvious place to muck with exceptions, but it would mean that exceptions that
are created but not thrown don't get the localization. I suspect that's a
fairly small problem in the real world, but it still carries code smell. As
does the whole idea of overriding methods.&lt;/p&gt;

&lt;h2&gt;Another sledgehammer: alternative setting&lt;/h2&gt;

&lt;p&gt;Perl 6 provides built-in types and routines in an outer lexical scope known
as a &quot;setting&quot;. The default setting is called CORE.
Due to the lexical nature of almost all lookups in Perl 6,
one can &quot;override&quot; almost anything by providing a symbol of the same name in a
lexical scope.&lt;/p&gt;

&lt;p&gt;One way to use that for localization is to add another setting between the
user's code and CORE. For example a file &lt;code&gt;DE.setting&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synSpecial&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;class&lt;/span&gt; X::Signature::Placeholder &lt;span class=&quot;synPreProc&quot;&gt;does&lt;/span&gt; X::Comp {
    &lt;span class=&quot;synStatement&quot;&gt;method&lt;/span&gt; message() {
        &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;Platzhaltervariablen können keine bestehenden Signaturen überschreiben&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
    }
}
&lt;/pre&gt;

&lt;p&gt;After compiling, we can load the setting:&lt;/p&gt;

&lt;pre&gt;
$ ./perl6 --target=pir --output=DE.setting.pir DE.setting
$ ./install/bin/parrot -o DE.setting.pbc DE.setting.pir
$ ./perl6 --setting=DE -e 'sub f() { $^x }'
===SORRY!===
Platzhaltervariablen können keine bestehenden Signaturen überschreiben
at -e:1
&lt;/pre&gt;

&lt;p&gt;That works beautifully for exceptions that the compiler throws, because
they look up exception types in the scope where the error occurs. Exceptions
from within the setting are a different beast, they'd need special lookup
rules (though the setting throws far fewer exceptions than the compiler, so
that's probably manageable).&lt;/p&gt;

&lt;p&gt;But while this looks quite simple, it comes with a problem: if a module is
precompiled without the custom setting, and it contains a reference to an
exception type, and then the l10n setting redefines it, other programs will
contain references to a different class with the same name. Which means that
our precompiled module might only catch the English version of
&lt;code&gt;X::Signature::Placeholder&lt;/code&gt;, and lets our localized exception pass
through. Oops.&lt;/p&gt;

&lt;h2&gt;Tailored solutions&lt;/h2&gt;

&lt;p&gt;A better approach is probably to simply hack up the string conversion in
type &lt;code&gt;Exception&lt;/code&gt; to consider a translator routine if present, and
pass the invocant to that routine. The translator routine can look up the
error message keyed by the type of the exception, and has access to all data
carried in the exception. In untested Perl 6 code, this might look like
this:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synComment&quot;&gt;# required change in CORE&lt;/span&gt;
&lt;span class=&quot;synSpecial&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;synType&quot;&gt;Exception&lt;/span&gt; {
    &lt;span class=&quot;synStatement&quot;&gt;multi&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;method&lt;/span&gt; Str(&lt;span class=&quot;synType&quot;&gt;Exception&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;D&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;) {
        &lt;span class=&quot;synSpecial&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;message &lt;span class=&quot;synStatement&quot;&gt;unless&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;defined&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;LANG&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;synStatement&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;TRANSLATIONS&lt;/span&gt;{&lt;span class=&quot;synIdentifier&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;LANG&lt;/span&gt;}{&lt;span class=&quot;synIdentifier&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.^&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;name&lt;/span&gt;} &lt;span class=&quot;synStatement&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$translator&lt;/span&gt; {
            &lt;span class=&quot;synSpecial&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$translator&lt;/span&gt;(&lt;span class=&quot;synIdentifier&quot;&gt;self&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
        }
        &lt;span class=&quot;synSpecial&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;message&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;synComment&quot;&gt;# fallback&lt;/span&gt;
    }
}

&lt;span class=&quot;synComment&quot;&gt;# that's what a translator could write:&lt;/span&gt;

&lt;span class=&quot;synIdentifier&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;TRANSLATIONS&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;de&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;X::TypeCheck::Assignment&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt; {
        &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;Typenfehler bei Zuweisung zu '&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;$_&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;symbol()&lt;span class=&quot;synConstant&quot;&gt;': &lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;
        &lt;span class=&quot;synStatement&quot;&gt;~&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;'&lt;/span&gt;{&lt;span class=&quot;synIdentifier&quot;&gt;$_&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;expected&lt;span class=&quot;synStatement&quot;&gt;.^&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;name&lt;/span&gt;}&lt;span class=&quot;synConstant&quot;&gt;' erwartet, aber '&lt;/span&gt;{&lt;span class=&quot;synIdentifier&quot;&gt;$_&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;got&lt;span class=&quot;synStatement&quot;&gt;.^&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;name&lt;/span&gt;}&lt;span class=&quot;synConstant&quot;&gt; bekommen&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;
    }
}
&lt;/pre&gt;

&lt;p&gt;And setting the dynamic language &lt;code&gt;$*LANG&lt;/code&gt; to &lt;code&gt;'de'&lt;/code&gt;
would give a German error message for type check failures in assignment.&lt;/p&gt;

&lt;p&gt;Another approach is to augment existing error classes and add methods that
generate the error message in different languages, for example &lt;code&gt;method
message-fr&lt;/code&gt; for French, and check their existence in
&lt;code&gt;Exception.Str&lt;/code&gt; if a different language is requested.&lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;In conclusion there are many bad and enough good approaches; we will decide
which one to take when the need arises (ie when people actually start to
translate error messages).&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/2012-grant-report-final-status-update.html">
 <title>Exceptions Grant Report -- Final update</title>
  <link>http://perlgeek.de/blog-en/perl-6/2012-grant-report-final-status-update.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Tue, Jun  5 19:49:28 2012</pubDate>
    <description>&lt;!-- 1338918568 --&gt;

&lt;p&gt;In my &lt;a
href=&quot;http://perlgeek.de/blog-en/perl-6/2012-grant-report-exceptions-may.html&quot;&gt;previous
blog post&lt;/a&gt; I mentioned that I'm nearly done with my &lt;a
href=&quot;http://news.perlfoundation.org/2011/02/hague-grant-application-struct.html&quot;&gt;exceptions
Hague grant&lt;/a&gt;. I have since done all the things that I identified as still
missing.&lt;/p&gt;

&lt;p&gt;In particular I &lt;a href=&quot;http://search.cpan.org/perldoc?ack&quot;&gt;ack&lt;/a&gt;
through the setting for remaining uses of &lt;code&gt;die&lt;/code&gt;, and the only thing
left are internal errors, error messages about not-yet-implemented things and
the actual declaration of &lt;code&gt;die&lt;/code&gt;. Which means that everything that
should be a typed exception is now.&lt;/p&gt;

&lt;p&gt;The error catalogue can be found in &lt;a
href=&quot;http://perlcabal.org/syn/S32/Exception.html&quot;&gt;S32::Exception&lt;/a&gt;.
Documentation for &lt;a
href=&quot;https://github.com/perl6/mu/blob/master/docs/exceptions.pod&quot;&gt;compiler
writers is in a separate document&lt;/a&gt;, and the promised &lt;a
href=&quot;https://github.com/perl6/roast/blob/master/packages/Test/Util.pm#L177&quot;&gt;documentation
for test authors is in the POD of Test::Util&lt;/a&gt; in the &quot;roast&quot;
repository.&lt;/p&gt;

&lt;p&gt;Now I wait for review of my work by the grant manager (thanks Will) and the
grant committee.&lt;/p&gt;

&lt;p&gt;I'd like to thank everybody who was involved with the grant.&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/2012-grant-report-exceptions-may.html">
 <title>Exceptions Grant Report for May 2012</title>
  <link>http://perlgeek.de/blog-en/perl-6/2012-grant-report-exceptions-may.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Sun, May 27 20:11:13 2012</pubDate>
    <description>&lt;!-- 1338142273 --&gt;

&lt;p&gt;It seems quite a long time since I started working on my &lt;a
href=&quot;http://news.perlfoundation.org/2011/02/hague-grant-application-struct.html&quot;&gt;grant
    on exceptions&lt;/a&gt;, and I until quite recently I felt that I still had
quite a long way to go. And then I read the deliverables again, and found that
I have actually achieved quite a bit of them already. I also noticed that some
of them are quite ambiguously formulated.&lt;/p&gt;

&lt;p&gt;Also when I wrote the grant application I had a clever system in the back
of my mind that lets you categorize exceptions with different tags. After
presenting that idea to the #perl6 channel, they uniformly told me that it was
a (bad) reinvention of the existing type system. They were right, of course.
So instead exceptions use the &quot;real&quot; type system now, which means that some
aspects of the grant application do not make so much sense now.&lt;/p&gt;

&lt;p&gt;Let's look at the deliverables in detail:&lt;/p&gt;

&lt;blockquote&gt;D1: Specification&lt;/blockquote&gt;

&lt;p&gt;&lt;a href=&quot;http://perlcabal.org/syn/S32/Exception.html&quot;&gt;S32::Exception&lt;/a&gt;
contains my work in this area.&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Since exceptions use the normal Perl 6 type system, the amount of work I
had to do was less than I had expected. I consider it done, in the sense
that everything is there that we need to throw typed exceptions and work with
them in a meaningful and intuitive way.&lt;/p&gt;

&lt;p&gt;There are certainly still open design question in the general space of
exceptions (like, how do we indicate that an exception should or should not
print its backtrace by default? There are ways to achieve this right now,
but it's not as easy as it it should be for the end user). However those open
questions are well outside the realm of this grant. I still plan to tackle
them in due time.&lt;/p&gt;

&lt;blockquote&gt;D2: Error catalog, tests&lt;/blockquote&gt;

&lt;p&gt;The error catalog is compiled and in Rakudo's &lt;a
href=&quot;https://github.com/rakudo/rakudo/blob/nom/src/core/Exception.pm&quot;&gt;src/core/Exception.pm&lt;/a&gt;.
It is not comprehensive (ie doesn't cover all possible errors that are thrown
from current compilers), but the grant request only required an &quot;initial&quot;
catalog. It is certainly enough to demonstrate the feasibility of the design,
and to handle many very common cases. I will certainly summarize it in the
S32::Exception document.&lt;/p&gt;

&lt;p&gt;Tests are in &lt;a
href=&quot;https://github.com/perl6/roast/blob/master/S32-exceptions/misc.t&quot;&gt;the
roast repository&lt;/a&gt;. At the time of writing there are 343 tests &lt;em&gt;(Update
2012-06-04: 411 tests)&lt;/em&gt;, of which
Rakudo passes nearly all (the few failures are due to misparses, which cause
wrong parse errors to be generated). They cover both the exceptions API and
the individual exception types.&lt;/p&gt;

&lt;blockquote&gt;D3: Implementation, tests, documentation&lt;/blockquote&gt;

&lt;p&gt;The meat of the implementation is done. Not all exceptions thrown from the
setting are typed yet, about 30 remain (plus a few for internal errors that
don't make sense to improve much). &lt;em&gt;(Update 2012-06-04: all of these 30
    errors now throw typed exceptions too).&lt;/em&gt;
The tests mentioned above already cover
several RT tickets where people complained about wrong or less-than-awesome
errors. Documentation is still missing, though I have &lt;a
href=&quot;http://irclog.perlgeek.de/perl6/2012-02-27#i_5216391&quot;&gt;given a
walk through the process of adding a new typed exception to Rakudo&lt;/a&gt; on IRC,
which might serve as a starting point for such documentation.&lt;/p&gt;

&lt;p&gt;So in summary, still missing are&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;Finish changing text based exceptions to typed exceptions in CORE&lt;/li&gt;
    &lt;li&gt;Documenting the error catalog in S32::Exception&lt;/li&gt;
    &lt;li&gt;Documentation for compiler writers and test writers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A surprisingly short list :-)&lt;/p&gt;

&lt;p&gt;I'd also like to mention that I did several things related to exceptions
which were not covered by this grant report:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;http://perlgeek.de/blog-en/perl-6/2011-02-exceptions.writeback&quot;&gt;greatly improved backtrace printer&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;Many exceptions from within the compilation process (such as parse
    errors, redeclarations etc.) are now typed.&lt;/li&gt;
    &lt;li&gt;I enabled typed exceptions thrown from C code, and as a proof of
    concept I ported all user-visible exceptions in &lt;a
    href=&quot;https://github.com/rakudo/rakudo/blob/nom/src/ops/perl6.ops&quot;&gt;perl6.ops&lt;/a&gt;
    to their intended types.&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;https://github.com/rakudo/rakudo/commit/ecf355fa54492999de368a4ca1aed21a016470ec&quot;&gt;Exceptions
    from within the meta model&lt;/a&gt; can now be caught in the &quot;actions&quot; part of
the compiler, augmented with line numbers and file name and re-thrown&lt;/li&gt;
&lt;/ul&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/2012-news-in-rakudo-2012-05-release.html">
 <title>News in the Rakudo 2012.05 release</title>
  <link>http://perlgeek.de/blog-en/perl-6/2012-news-in-rakudo-2012-05-release.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Wed, May 23 10:25:46 2012</pubDate>
    <description>&lt;!-- 1337761546 --&gt;

&lt;p&gt;The &lt;a
href=&quot;http://rakudo.org/2012/05/23/rakudo-star-2012-05-released/&quot;&gt;Rakudo
Star release 2012.05&lt;/a&gt; comes with many improvements to the compiler. Some
people have asked what they mean, so I want to explain some of them here.&lt;/p&gt;

&lt;p&gt;The new &lt;b&gt;-I&lt;/b&gt; and &lt;b&gt;-M&lt;/b&gt; allow manipulation of the library search
path and loading of modules, similar &lt;a
href=&quot;http://perldoc.perl.org/perlrun.html&quot;&gt;to Perl 5&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;
perl6 -Ilib t/yourtest.t  # finds your module under lib/
&lt;/pre&gt;

&lt;p&gt;If you want to manipulate the search path from inside a script
or module, you can now use the new &lt;b&gt;lib&lt;/b&gt; module, again
&lt;a href=&quot;http://perldoc.perl.org/lib.html&quot;&gt;known from Perl 5&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synComment&quot;&gt;# file t/yourtest.t;&lt;/span&gt;
&lt;span class=&quot;synPreProc&quot;&gt;use&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;v&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synPreProc&quot;&gt;use&lt;/span&gt; lib &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;t/lib&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;synComment&quot;&gt;# now can load testing modules from t/lib/Yourmodule/Test.pm&lt;/span&gt;
&lt;span class=&quot;synPreProc&quot;&gt;use&lt;/span&gt; Yourmodule::Test&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synStatement&quot;&gt;...&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;If you look at how &lt;a
href=&quot;https://github.com/rakudo/rakudo/blob/nom/lib/lib.pm&quot;&gt;lib.pm is
implemented&lt;/a&gt;, you'll notice another new feature: the ability to write a
custom &lt;code&gt;EXPORT&lt;/code&gt; subroutine -- necessary exactly for things like
lib.pm.&lt;/p&gt;

&lt;p&gt;But normal exporting and importing is now handled quite well from Rakudo.
You can now mark routines as being exported to certain tag names:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synStatement&quot;&gt;module&lt;/span&gt; CGI {
    &lt;span class=&quot;synStatement&quot;&gt;sub&lt;/span&gt; h1(&lt;span class=&quot;synIdentifier&quot;&gt;$text&lt;/span&gt;) &lt;span class=&quot;synIdentifier&quot;&gt;is&lt;/span&gt; export(&lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;HTML&lt;/span&gt;) { &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;~&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;$text&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;~&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt; }
    &lt;span class=&quot;synStatement&quot;&gt;sub&lt;/span&gt; param(&lt;span class=&quot;synIdentifier&quot;&gt;$key&lt;/span&gt;) &lt;span class=&quot;synIdentifier&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;export&lt;/span&gt; { &lt;span class=&quot;synStatement&quot;&gt;...&lt;/span&gt; }&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
}
&lt;/pre&gt;

&lt;p&gt;If you want to get only the HTML generating function(s), you can write&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synPreProc&quot;&gt;use&lt;/span&gt; CGI &lt;span class=&quot;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;HTML&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;&lt;a href=&quot;http://perlcabal.org/syn/S11.html&quot;&gt;S11&lt;/a&gt; has more details on the
exporting and importing mechanism.&lt;/p&gt;

&lt;p&gt;You can also import from within a single file by using &lt;code&gt;import&lt;/code&gt;
instead of &lt;code&gt;use&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synStatement&quot;&gt;module&lt;/span&gt; Greeter {
    &lt;span class=&quot;synStatement&quot;&gt;sub&lt;/span&gt; hello(&lt;span class=&quot;synIdentifier&quot;&gt;$who&lt;/span&gt;) &lt;span class=&quot;synIdentifier&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;export&lt;/span&gt; {
        &lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;Hello &lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;$who&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
    }
}

import Greeter&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;synComment&quot;&gt;# make sub hello available in the current scope&lt;/span&gt;
hello(&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;Perl 6 fans&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;



</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/2012-sqlite-in-dbiish.html">
 <title>SQLite support for DBIish</title>
  <link>http://perlgeek.de/blog-en/perl-6/2012-sqlite-in-dbiish.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Thu, May  3 11:02:47 2012</pubDate>
    <description>&lt;!-- 1336035767 --&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/perl6/DBIish/&quot;&gt;DBIish&lt;/a&gt;, the new database
interface for Rakudo Perl 6, now has a working SQLite backend. It uses
prepared statements and placeholders, and supports standard CRUD
operations.&lt;/p&gt;

&lt;p&gt;Previously the SQLite driver would randomly report &quot;Malformed UTF-8 string&quot;
or segfault, but usually worked pretty well when run under valgrind. The
problem turned out to be a mismatch between the caller's and the callee's
ideas about memory management.&lt;/p&gt;

&lt;p&gt;In particular, parrot's garbage collector would deallocate strings passed
to &lt;a href=&quot;http://www.sqlite.org/c3ref/bind_blob.html&quot;&gt;sqlite3_bind_text&lt;/a&gt;
after the call was done, but sqlite wants such values to stay around until
the next call to &lt;a
href=&quot;http://www.sqlite.org/c3ref/step.html&quot;&gt;sqlite3_step&lt;/a&gt; in the very
least.&lt;/p&gt;

&lt;p&gt;Fixing this mismatch was enabled &lt;a
    href=&quot;https://github.com/jnthn/zavolaj/commit/e94f45ca4dd5df3010ecb84051980f506e3cbe6d&quot;&gt;by
this patch&lt;/a&gt;, which lets you mark strings as explicitly managed. Such
strings keep their marshalled C string equivalent around until they are
garbage-collected themselves. So now &lt;a
    href=&quot;https://github.com/perl6/DBIish/commit/9b339432405228a895c76bf1193bdba3f935b99b&quot;&gt;the
sqlite driver keeps a copy of the strings&lt;/a&gt; as long as necessary, and the SQLite
tests pass reliably.&lt;/p&gt;

&lt;p&gt;Currently it still needs the &lt;code&gt;cstr&lt;/code&gt; branches in the nqp and
zavolaj repositories, but they will be merged soon -- certainly before the May
release of Rakudo.&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/2012-dbiish.html">
 <title>Meet DBIish, a Perl 6 Database Interface</title>
  <link>http://perlgeek.de/blog-en/perl-6/2012-dbiish.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Sat, Apr 28 12:03:10 2012</pubDate>
    <description>&lt;!-- 1335607390 --&gt;

&lt;p&gt;In the aftermath of the Oslo Perl 6 hackathon 2012, I have decided to fork
and rename MiniDBI. MiniDBI is intended as a compatible port of Perl 5's
excellent DBI module to Perl 6. While working on the MiniDBI backends, I
noticed that I became more and more unhappy with that. Perl 6 is sufficiently
different from Perl 5 to warrant different design decisions in the database
interface layer.&lt;/p&gt;

&lt;p&gt;Meet &lt;a href=&quot;https://github.com/perl6/DBIish/&quot;&gt;DBIish&lt;/a&gt;. It started with
MiniDBI's code base, but has some substantial deviations from MiniDBI:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;Connection information is passed by named arguments to the driver
    (instead of a single DSN string)&lt;/li&gt;
    &lt;li&gt;Different naming of several methods. There's not much point in having
    both &lt;code&gt;fetchrow_array&lt;/code&gt; and &lt;code&gt;fetchrow_arrayref&lt;/code&gt; in
    Rakudo. &lt;code&gt;fetchrow&lt;/code&gt; simply returns an array or a list, and the
    caller decides what to do with it.&lt;/li&gt;
    &lt;li&gt;Backends only need to implement &lt;code&gt;fetchrow&lt;/code&gt; and
    &lt;code&gt;column_names&lt;/code&gt;, and get all the other fetching methods (like
    &lt;code&gt;fetchrow-hash&lt;/code&gt;, &lt;code&gt;fetchall-hash&lt;/code&gt;) for free.&lt;/li&gt;
    &lt;li&gt;Error handling from DB connection and statement handle are unified
    into a single row&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The latter two changes brought quite a reduction in backend code size.&lt;/p&gt;

&lt;p&gt;My plans for the future include experimenting with different names and
maybe totally different APIs. When a language has lazy lists, one can simply
return all rows lazily, instead of encouraging the user to fetch the rows one
by one.&lt;/p&gt;

&lt;p&gt;Currently the Postgresql and mysql backends support basic CRUD operations,
Postgresql with proper prepared statements and placeholders. An SQLite backend
is under way, but still needs better support from our native call interface.&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/2012-oslo-hackathon-rest.html">
 <title>Perl 6 Hackathon in Oslo: Report From The Second Day</title>
  <link>http://perlgeek.de/blog-en/perl-6/2012-oslo-hackathon-rest.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Mon, Apr 23 09:24:30 2012</pubDate>
    <description>&lt;!-- 1335165870 --&gt;

&lt;p&gt;Second day of the &lt;a href=&quot;https://gist.github.com/1711730&quot;&gt;Perl 6 Patterns
Hackathon&lt;/a&gt;. My plans to get the rest of placeholders and prepared
statements working in the Postgresql backend for MiniDBI succeed about 10
minutes after midnight. I just wanted to give them a very quick try before
going to bed, and was successful. Then I went to sleep.&lt;/p&gt;

&lt;p&gt;It was night, and it was morning. Second day.&lt;/p&gt;

&lt;p&gt;Next I wrote an SQLite backend for MiniDBI. It blocked on missing features
in our native call infrastructure, on which arnsholt worked in parallel. So I
haven't had a chance to try the SQLite backend yet. It probably requires some
substantial amount of work before it will run, but at least it compiles.&lt;/p&gt;

&lt;p&gt;I also investigated prepared statements and placeholders for the mysql
backend. This is much less straight forward, because it requires filling in
members of structs, not just function calls. This by itself wouldn't be much a
problem, our native call infrastructure supports that. The problem is that
it's a struct of mixed &quot;private&quot; and &quot;public&quot; members, so modelling the
structure in Perl 6 requires modeling private data of the mysql client
library. While possible, I don't find it desirable, because it is rather
fragile.&lt;/p&gt;

&lt;p&gt;Another notable event was the hacking dojo, where about 8 of us
collaborated to write a roman numeral conversion, using pair programming, and
fixed cycles of first writing a failing test, then getting it to run in the
simplest possible way, and finally refactoring it. It was quite an interesting
and fun experience.&lt;/p&gt;

&lt;p&gt;I spent much of the rest of the hackathon discussing things. For example
Patrick Michaud gave a quick walk through of how lists and related types are
implemented and iterated in Rakudo.&lt;/p&gt;

&lt;p&gt;In the evening we had very tasty Vietnamese food, and generally a good
time.&lt;/p&gt;

&lt;p&gt;Again it was a very productive and enjoyable day, and I'm very grateful for
being invited to the Hackathon.&lt;/p&gt;



</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/2012-oslo-hackathon-report.html">
 <title>Perl 6 Hackathon in Oslo: Report From The First Day</title>
  <link>http://perlgeek.de/blog-en/perl-6/2012-oslo-hackathon-report.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Sat, Apr 21 22:10:48 2012</pubDate>
    <description>&lt;!-- 1335039048 --&gt;

&lt;p&gt;Yesterday I arrived in the beautiful city of Oslo to attend the &lt;a
href=&quot;https://gist.github.com/1711730&quot;&gt;Perl 6 Patterns Hackathon&lt;/a&gt;.
Yesterday we visited a pub, had great discussions, food and beverages, and
generally a very good time.&lt;/p&gt;

&lt;p&gt;Today we met at 10 am, and got straight to hacking. We are located in an
office in the 6th floor of a big building, with a nice view over the center of
town, harbor, and even the Holmenkollen.&lt;/p&gt;

&lt;p&gt;I worked on the backtrace printer, which in alarmingly many cases reported
&lt;code&gt;Error while creating error string: Method 'message' not found for
invocant of class 'Any'&lt;/code&gt;, which wasn't too helpful.&lt;/p&gt;

&lt;p&gt;It turns out there were actually two causes. One was a subtle error in the
backtrace printer that was triggered by &lt;a
    href=&quot;https://github.com/rakudo/rakudo/commit/6ef66c9521b14f33ded88c3da8569032488d2442&quot;&gt;stricter
    implementation of the specification&lt;/a&gt;, which was easy to find. The
second bug was harder to find, considering that you don't get easily get
backtraces from errors within the backtrace printer. In the end it was the
usage of a code object in boolean context, which turned out to be harmful.
Because regexes are also code objects, and in boolean context they search for
the outer &lt;code&gt;$_&lt;/code&gt; variable and try to match the regex against it.
Which failed. Hard to find, but easy to fix.&lt;/p&gt;

&lt;p&gt;My second big project today was database connectivity. Part of it was
pestering Jonathan to fix the issues that arose from module precompilation
mixed with calling C modules, and testing all the iterations he produced. I'm
happy to report that it now works fine, which speeds up development quite a
bit.&lt;/p&gt;

&lt;p&gt;I also fixed the postgres driver. The root cause for the failing tests
turned out to be rather simple too (a missing initialization), so simple that
it's embarrassing how long it took me to find out. On the plus side I improved
the code quite a bit in passing.&lt;/p&gt;

&lt;p&gt;So now all tests in &lt;a
href=&quot;https://github.com/mberends/MiniDBI&quot;&gt;MiniDBI&lt;/a&gt; pass, which is a nice
milestone, and an indication that we need more tests.&lt;/p&gt;

&lt;p&gt;Tomorrow I plan to change the postgres driver to use proper prepared
statments.&lt;/p&gt;

&lt;p&gt;But the real value of such hackathon comes from interacting with the other
hackers. I'm very happy about lots of discussions with other core hackers, as
well as feedback and patches from new users and hackers.&lt;/p&gt;

&lt;p&gt;At this occasion I'd also like to thank the organizers, Salve J. Nilsen,
Karl Rune Nilsen and Jan Ingvoldstad. It has been a great event so far, both fun and productive. You are
doing a great service to the Perl 6 community, and to the hackers you have
invited.&lt;/p&gt;



</description>
  </item>
 
</rdf:RDF>