<?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/rakudo-memory-leaks.html">
 <title>Fixing Rakudo Memory Leaks</title>
  <link>http://perlgeek.de/blog-en/perl-6/rakudo-memory-leaks.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Thu, Aug 26 13:52:12 2010</pubDate>
    <description>&lt;!-- 1282823532 --&gt;

&lt;p&gt;Rakudo has been leaking memory for a few month. The other day, after some
nagging, Will Coleda identified a memory leak, and Tyler Curtis &lt;a
href=&quot;http://github.com/rakudo/rakudo/commit/3a339ee8ab3a72867fe914ec9c689e1f5a890645&quot;&gt;fixed
it&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now we can again make long-running processes with Rakudo. For example for
my talk at YAPC::EU I plotted a &lt;a
href=&quot;http://perlgeek.de/talks/2010/yapceu-p6-realworld/resonance.png&quot;&gt;resonance 
curve&lt;/a&gt;. For that I needed to start a new Rakudo process for every data
point because it would leak so badly that it died after processing a few data
points. Now I recalculated a whole curve in one process, with memory usage not
exceeding 200MB of virtual mem.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://perlgeek.de/images/blog/res2.png&quot; width=&quot;702&quot; height=&quot;506&quot;
alt=&quot;resonance curve&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I also had some fun recalculating a mandelbrot fractal in a size that would
previously make Rakudo segfault or consume too much memory.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://perlgeek.de/images/blog/mandel-color.png&quot; width=&quot;1001&quot;
height=&quot;1001&quot; alt=&quot;Mandelbrot fractal, rendered by Rakudo&quot; /&gt;&lt;/p&gt;

&lt;p&gt;(Rendered with &lt;a href=&quot;http://github.com/colomon/mandelbrot/&quot;&gt;colomon's
mandelbrot code)&lt;/a&gt;).&lt;/p&gt;



</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/pascal-triangle.html">
 <title>Pascal's Triangle in Perl 6</title>
  <link>http://perlgeek.de/blog-en/perl-6/pascal-triangle.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Wed, Aug 25 17:03:32 2010</pubDate>
    <description>&lt;!-- 1282748612 --&gt;

&lt;p&gt;Today on IRC, Larry Wall showed this piece of Perl 6 code, which he wrote
for &lt;a href=&quot;http://rosettacode.org/wiki/Pascal%27s_triangle#Perl_6&quot;&gt;Rosetta
Code&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synStatement&quot;&gt;sub&lt;/span&gt; pascal { [&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;synStatement&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@p&lt;/span&gt; { [&lt;span class=&quot;synConstant&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@p&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;Z+&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@p&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;0&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;synStatement&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; pascal[&lt;span class=&quot;synStatement&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;10&lt;/span&gt;]&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;perl&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;# output (reformatted for easy readbility):&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;# ([1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 2, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 3, 3, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 4, 6, 4, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 5, 10, 10, 5, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 6, 15, 20, 15, 6, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 7, 21, 35, 35, 21, 7, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 8, 28, 56, 70, 56, 28, 8, 1],&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;#  [1, 9, 36, 84, 126, 126, 84, 36, 9, 1])&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;That's &lt;a href=&quot;http://en.wikipedia.org/wiki/Pascal%27s_triangle&quot;&gt;Pascal's
triangle&lt;/a&gt;, generated in one line of Perl 6.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;...&lt;/code&gt; is the series operator, which generates lists by
feeding the previous value(s) (here always one array) to the generating
block on its left, until it reaches the goal on the right (in this case
&quot;whatever&quot;, which means it returns a lazy, infinite list).&lt;/p&gt;

&lt;p&gt;So for example if the previous item was the array &lt;code&gt;[1, 2, 1]&lt;/code&gt;,
the code block evaluates &lt;code&gt;0, 1, 2, 1 Z+ 1, 2, 1, 0&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Z&lt;/code&gt; is the zip operator, &lt;code&gt;Z+&lt;/code&gt; is pairwise addition
(ie adding the pairs that the zip operator produced). In our example that
leads to &lt;code&gt;0+1, 1+2, 2+1, 1+0&lt;/code&gt; or &lt;code&gt;1, 3, 3, 1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It takes a while to get used to the meta operators and the series operator,
but once you've understood them, you can do pretty neat things with them.&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/not-zero-sum.html">
 <title>Programming Languages Are Not Zero Sum</title>
  <link>http://perlgeek.de/blog-en/perl-6/not-zero-sum.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Mon, Aug 23 10:54:54 2010</pubDate>
    <description>&lt;!-- 1282553694 --&gt;

&lt;p&gt;From &lt;a href=&quot;http://en.wikipedia.org/wiki/Zero-sum&quot;&gt;Wikipedia, the free
    encyclopedia&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;
    In game theory and economic theory, zero-sum describes a situation
    in which a participant's gain or loss is exactly balanced by the losses or
    gains of the other participant(s). If the total gains of the participants
    are added up, and the total losses are subtracted, they will sum to zero.
&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Being advocate, implementor, tester and co-designer of a &lt;a
href=&quot;http://perl6.org/&quot;&gt;new programming language&lt;/a&gt;, I often hear objections
along the lines of &lt;em&gt;you are killing &lt;a
href=&quot;http://www.perl.org/&quot;&gt;$other_programming_language&lt;/a&gt;&lt;/em&gt;, combined
with a mixture of fear and resentment. People are afraid that having a new
player on the market will decrease
market share of their own, favorite programming language.&lt;/p&gt;

&lt;p&gt;While I can understand these thinking patterns, there is no reason for
concern. The market for programming languages is not a zero-sum situation.
While I don't have hard data, I have the impression that the programming job
sector is growing, and &lt;a
href=&quot;http://www.bls.gov/oco/ocos303.htm#projections_data&quot;&gt;the US
government expects it to grow&lt;/a&gt; further, too.&lt;/p&gt;

&lt;p&gt;Certainly the &lt;a
href=&quot;http://upload.wikimedia.org/wikipedia/commons/7/77/World-Population-1800-2100.png&quot;&gt;growth
of world population&lt;/a&gt; sets a rapidly increasing baseline, and even if we
assume a constant percentage of all people related to programming in some way,
the total number of programmers rises, and will continue for quite some
time.&lt;/p&gt;

&lt;p&gt;(I'm pointing to some resources about programming jobs, and I fully realize that
it's not the same as number of overall programmers; but it's easier to get
data for jobs, and I do think that the general trend statements are true for
both).&lt;/p&gt;

&lt;p&gt;So as long as the total number of programmers increases, a decrease in
relative market share doesn't automatically mean a loss. In fact &lt;a
    href=&quot;http://duartes.org/gustavo/blog/post/programming-language-jobs-and-trends&quot;&gt;the
job trends show an increase for &quot;scripting&quot; languages&lt;/a&gt;, and while Ruby is
certainly the winner in terms of growth, Python, Perl and PHP win too!&lt;/p&gt;

&lt;p&gt;Non-job data shows for example a &lt;a
href=&quot;http://stats.cpantesters.org/graphs12.html&quot;&gt;noisy but steady growth
of uploads to the Comprehensive Perl Archive Network (CPAN)&lt;/a&gt; -- data from a
programming language that is often perceived as a loser of ruby's and python's
success.&lt;/p&gt;

&lt;p&gt;A recent &lt;a
href=&quot;http://linuxtrends.com/linux-distribution-popularity-trends/&quot;&gt;Linux
distribution trend analysis&lt;/a&gt; fell into the same trap: it shows
&lt;strong&gt;relative&lt;/strong&gt; numbers of search terms, and talks about a decline
for all distributions except Ubuntu. Again I don't have hard numbers (the
mirror infrastructure of most Linux distributions makes it nearly impossible
to get accurate download counts), but I haven't seen any evidence that total
usage numbers of any of the Linux distributions actually decreased.&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/state-of-regex-modifiers.html">
 <title>The State of Regex Modifiers in Rakudo</title>
  <link>http://perlgeek.de/blog-en/perl-6/state-of-regex-modifiers.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Mon, Aug 16 17:16:15 2010</pubDate>
    <description>&lt;!-- 1281971775 --&gt;

&lt;p&gt;During the last one and a half month, I've been working on making regex
modifiers easily available in Rakudo.&lt;/p&gt;

&lt;p&gt;The regex compiler itself has to support only a few of the adverbs that can
be applied to regexes; those include :ignorecase, :sigspace, :ignoremark and
:continue/:pos. NQP-rx, the regex engine that Rakudo uses under the hood,
supports those (except :ignoremark), so previously you could write&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synStatement&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;ABC&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;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;i abc&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&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;case insensitive match&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;/pre&gt;


&lt;p&gt;But not&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synStatement&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;ABC&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;synStatement&quot;&gt;rx:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;abc&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&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;case insensitive match&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;/pre&gt;

&lt;p&gt;nor &lt;code&gt;m:i/abc/&lt;/code&gt;, for that matter.&lt;/p&gt;

&lt;p&gt;I've patched Rakudo to actually recognize those adverbs outside of the
regex, and also for &lt;code&gt;s///&lt;/code&gt; substitutions.&lt;/p&gt;

&lt;p&gt;Another category of adverbs are those that apply to regex calls, not to the
compilation of a regex. Among those are :global/:g, :overlap/:ov, :nth($n),
:x. I've implemented those for substitutions, but implementing them for
&lt;code&gt;m//&lt;/code&gt; turns  out to be quite a bit harder.&lt;/p&gt;

&lt;p&gt;The reason is the return value: each regex match returns a Match object,
which can store positional and named parts. &lt;a
href=&quot;http://pugscode.org/syn/S05.html&quot;&gt;S05&lt;/a&gt; says that regex matches
with multiple results should return a single match object, with all results as
positional parts. It can be distinguished from a normal match object by
evaluating it in slice context... which Rakudo doesn't support yet.&lt;/p&gt;

&lt;p&gt;Now the &lt;code&gt;subst&lt;/code&gt; method and thus &lt;code&gt;s///&lt;/code&gt; are
implemented by calling &lt;code&gt;.match(:global, ...)&lt;/code&gt;, and without slice
context, it can't distinguish between multiple matches, and a single match
with subcaptures. And so my changes to the global match broke the
substitution, and I see no easy way to fix it.&lt;/p&gt;

&lt;p&gt;Anyway, here are a few examples of what works today:&lt;/p&gt;

&lt;pre&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;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;ab12fg34&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;synStatement&quot;&gt;s:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;g&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/\d/&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;X&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;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;synComment&quot;&gt;# output: abXXfgXX&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;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;Hello, World&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;# :ii is the same as :samecase&lt;/span&gt;
&lt;span class=&quot;synStatement&quot;&gt;s:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;ii&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;world&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;perl&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;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;synComment&quot;&gt;# output: Hello, Perl&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;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;I did not know that that work together&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;synStatement&quot;&gt;s:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;2nd&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;that&lt;/span&gt;&lt;span class=&quot;synSpecial&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;they&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;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;synComment&quot;&gt;# output: I did not know that they work together&lt;/span&gt;
&lt;/pre&gt;

 
</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/cool.html">
 <title>What is the &quot;Cool&quot; class in Perl 6?</title>
  <link>http://perlgeek.de/blog-en/perl-6/cool.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Thu, Aug 12 15:28:39 2010</pubDate>
    <description>&lt;!-- 1281619719 --&gt;

&lt;p&gt;In Perl, subroutine and operator names determine what happens, usually not
the type of the arguments. Instead the arguments are coerced to a type on
which the operation makes sense:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;say&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;uc&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;34&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;      &lt;span class=&quot;synComment&quot;&gt;# coerces 34 to a string, and upper-cases it&lt;/span&gt;
&lt;span class=&quot;synIdentifier&quot;&gt;say&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;synSpecial&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;2&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;synComment&quot;&gt;# converts &amp;quot;2&amp;quot; to a number before adding&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;To make things more extensible, the &lt;code&gt;uc&lt;/code&gt; function re-dispatches
to the &lt;code&gt;uc&lt;/code&gt; method on its argument. So for the example above to
work, we need an &lt;code&gt;uc&lt;/code&gt; function in Int. And in Array, so that
&lt;code&gt;@a.uc&lt;/code&gt; works. And so on.&lt;/p&gt;

&lt;p&gt;The original approach was to stuff all these methods into &lt;code&gt;Any&lt;/code&gt;,
the base class of the object hierarchy. Which kinda worked, but also meant
that all user-defined classes ended up having some few hundreds methods to
start with. Not good.&lt;/p&gt;

&lt;p&gt;These days, the type &lt;code&gt;Cool&lt;/code&gt; fills this niche: most built-in types
(all that are meant to be used in that polymorphic way) inherit from Cool, so
the &lt;code&gt;uc&lt;/code&gt; method is actually defined in class &lt;code&gt;Cool&lt;/code&gt;,
coerces to string, and then re-dispatches to the internal logic that actually
does the upper-casing.&lt;/p&gt;

&lt;p&gt;The name either stands for &lt;em&gt;&lt;strong&gt;C&lt;/strong&gt;onvenient
    &lt;strong&gt;o&lt;/strong&gt;bject &lt;strong&gt;o&lt;/strong&gt;riented
    &lt;strong&gt;l&lt;/strong&gt;oopback&lt;/em&gt;, or just expresses that that most
built-ins are cool with an argument of that type.&lt;/p&gt;

&lt;p&gt;If users want to write a type that can be used like a built-in type now
just inherit from &lt;code&gt;Cool&lt;/code&gt;, and define coercion methods to other
built-in types. If the types don't inherit from &lt;code&gt;Cool&lt;/code&gt;, they are
more light-weight, and less magic. There's more than one way to do it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Cool&lt;/code&gt; is a class (and not a role), because classes are mutable;
so if you want to inject behavior into nearly all built-in types, augmenting
&lt;code&gt;Cool&lt;/code&gt; is an option (though usually considered evil, and should not
be done lightly).&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-tips/what-is-modern-perl.html">
 <title>What is &quot;Modern Perl&quot;?</title>
  <link>http://perlgeek.de/blog-en/perl-tips/what-is-modern-perl.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Thu, Aug 12 15:17:32 2010</pubDate>
    <description>&lt;!-- 1281619052 --&gt;

&lt;p&gt;These days you often hear term &lt;em&gt;Modern Perl&lt;/em&gt;, as something new(ish),
and much improved over the old ways.&lt;/p&gt;

&lt;p&gt;But what is it exactly? Well, there's no proper definition, but here is
what that term means to me:&lt;/p&gt;

&lt;p&gt;It's a set of tools, ideas and attitudes that help you to write better Perl
programs, and allows you to have more fun while writing them.&lt;/p&gt;

&lt;p&gt;Here are some aspects of Modern Perl&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;Testing: Most modern Perl modules have extensive test suites, that
    make development sane and robust&lt;/li&gt;
    &lt;li&gt;Some built-ins now come with safer forms: the &lt;a
    href=&quot;http://perldoc.perl.org/functions/open.html&quot;&gt;three-argument form
    of open()&lt;/a&gt; allows you to open files safely with arbitrary characters in
    them, without any extra precautions. Lexical file handles make things safer
    and easier too.&lt;/li&gt;
    &lt;li&gt;&lt;code&gt;use &lt;a
    href=&quot;http://perldoc.perl.org/strict.html&quot;&gt;strict&lt;/a&gt;; use &lt;a
    href=&quot;http://perldoc.perl.org/perllexwarn.html&quot;&gt;warnings&lt;/a&gt;;&lt;/code&gt;&lt;/li&gt;
    &lt;li&gt;Proper OO: with Perl 6 and with &lt;a
    href=&quot;http://www.iinteractive.com/moose/&quot;&gt;Moose&lt;/a&gt; in Perl 5, we have
    good object systems, that require less low-level fiddling than the
    standard Perl 5 object system&lt;/li&gt;
    &lt;li&gt;Following &lt;a href=&quot;http://www.linuxjournal.com/article/8567&quot;&gt;Best
        Practices&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;(For open source projects) Liberally handing out commit privileges.
    The source is stored in a version control system anyway, so low-quality
    changes or vandalism can simply be reverted (but that doesn't happen often
    in practice).&lt;/li&gt;
    &lt;li&gt;Caring about marketing: do tell people that you built something cool
    and useful&lt;/li&gt;
    &lt;li&gt;Small handy modules such as &lt;a
    href=&quot;http://search.cpan.org/perldoc?List::Util&quot;&gt;List::Util&lt;/a&gt; and &lt;a
    href=&quot;http://search.cpan.org/perldoc?Try::Tiny&quot;&gt;Try::Tiny&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;Development tools such as &lt;a
    href=&quot;http://search.cpan.org/perldoc?Devel::Cover&quot;&gt;Devel::Cover&lt;/a&gt;
    and &lt;a
        href=&quot;http://search.cpan.org/perldoc?Devel::NYTProf&quot;&gt;Devel::NYTProf&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;(update) &lt;a
        href=&quot;http://search.cpan.org/dist/App-perlbrew/&quot;&gt;perlbrew&lt;/a&gt; and &lt;a
        href=&quot;search.cpan.org/perldoc/local::lib&quot;&gt;local::lib&lt;/a&gt; to help
        maintain your own perl installation and locally installed
        modules.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of these techniques help to write scalable Perl programs by making
proper encapsulation much easier, or by avoiding common errors, identifying
performance bottlenecks etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; after watching some discussions about this post in
various media, I should add a few more tools that I forgot about earlier:&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;http://search.cpan.org/perldoc?Devel::REPL&quot;&gt;Devel::REPL&lt;/a&gt;,
    Read-Evaluation-Print Loop&lt;/li&gt;
    &lt;li&gt;&lt;a
        href=&quot;http://search.cpan.org/perldoc?Perl::Critic&quot;&gt;Perl::Critic&lt;/a&gt;,
        a code quality and style tester&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;http://search.cpan.org/perldoc?DBIx::Class&quot;&gt;DDBIx::Class&lt;/a&gt;,
        a modern and very popular object relational mapper&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;http://search.cpan.org/perldoc?Catalyst&quot;&gt;Catalyst&lt;/a&gt;,
        a web framework based on the MVC pattern&lt;/li&gt;
&lt;/ul&gt;

 
</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/perlmonks-questions.html">
 <title>Perl 6 Questions on Perlmonks</title>
  <link>http://perlgeek.de/blog-en/perl-6/perlmonks-questions.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Tue, Aug 10 11:18:42 2010</pubDate>
    <description>&lt;!-- 1281431922 --&gt;
&lt;p&gt;Since the Rakudo Star release, there has been a noticeable increase in Perl
6 questions on perlmonks - a good sign, because it means people are using
it.&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;&lt;a href=&quot;http://www.perlmonks.org/?node_id=853975&quot;&gt;Array interpolation
        in Rakudo&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;http://www.perlmonks.org/?node_id=853727&quot;&gt;Rakudo build
        problems&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;http://www.perlmonks.org/?node_id=853573&quot;&gt;Perl6, latest
        Rakudo bug or error on my part?&lt;/a&gt; (parsing issue related to missing
        whitespace).&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;http://www.perlmonks.org/?node_id=853149&quot;&gt;Perl6, modifying
        @*INC&lt;/a&gt; (another ws parsing issue)&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;http://www.perlmonks.org/?node_id=853113&quot;&gt;Perl6's
        LWP::Simple&lt;/a&gt; -- seemingly an installation issue&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;http://www.perlmonks.org/?node_id=852900&quot;&gt;Perl 6, defining a
        hash with interpolated string&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I've assembled this list by looking through the 100 newest nodes in &lt;a
href=&quot;http://www.perlmonks.org/?node=Seekers%20of%20Perl%20Wisdom&quot;&gt;Seekers of
Perl Wisdom&lt;/a&gt;, which makes it 6% of the questions asked, or on average 1 per
day (used to be around 1 per week).&lt;/p&gt;

&lt;p&gt;Most of the questions are related to environmental issues
(building/installing stuff), or beginner's questions related to syntax.&lt;/p&gt;

&lt;p&gt;It's good to see the questions flowing in, and I hope that we'll soon see
more questions where I can show off cool Perl 6 features in the answers
:-).&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/notes-from-yapc-hackathon.html">
 <title>Notes from the YAPC::EU 2010 Rakudo hackathon</title>
  <link>http://perlgeek.de/blog-en/perl-6/notes-from-yapc-hackathon.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Fri, Aug  6 16:48:40 2010</pubDate>
    <description>&lt;!-- 1281106120 --&gt;

&lt;p&gt;At YAPC::EU 2010 we had a long discussion about Perl 6, Rakudo and related
matters. Here are some (very incomplete) notes of the ongoing discussions and
results.&lt;/p&gt;

&lt;h2 id=&quot;attendees&quot;&gt;Attendees&lt;/h2&gt;

&lt;p&gt;Patrick Michaud, Jonathan Worthington, Carl Mäsak, Moritz Lenz, Gabor
Szabo, and a fluctuation of other Perl 6 hackers.&lt;/p&gt;

&lt;h2 id=&quot;speed&quot;&gt;Speed&lt;/h2&gt;
&lt;p&gt;What can we do to improve Rakudo's performance?&lt;/p&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;jnthn_s_grant_proposal_for_a_low_level_meta_object_protocol&quot; class=&quot;item&quot;&gt;jnthn's grant proposal for a low-level meta object protocol&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;See
&lt;a href=&quot;http://news.perlfoundation.org/2010/07/hague-grant-application-meta-m.html&quot;&gt;http://news.perlfoundation.org/2010/07/hague-grant-application-meta-m.html&lt;/a&gt;.
Will probably bring the biggest speed improvement of all options we have under
our control&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;rakudo_built_in_optimizations&quot; class=&quot;item&quot;&gt;Rakudo built-in optimizations&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;Most Rakudo built-ins are written for correctness first, and without a good
feeling for what constructs are fast and what aren't. A thorough review (and
preferably profiling) could bring decent speed improvements, as the case of
int ranges showed.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;garbage_collector&quot; class=&quot;item&quot;&gt;Garbage collector&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;Parrot's GC is... suboptimal. To be gentle.&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;optimization_framework&quot; class=&quot;item&quot;&gt;Optimization framework&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;We will try to convince people that Tyler Curtis' optimization framework for
PAST and POST should be shipped with parrot (probably compile PIRs in &lt;code&gt;ext/&lt;/code&gt;,
just like NQP-rx does it now). Using that, we can do constant folding&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;moving_stuff_to_compile_time&quot; class=&quot;item&quot;&gt;Moving stuff to compile time&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;Number parsing needs to be moved to compile time.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;

&lt;h2 id=&quot;what_do_we_need_to_keep_hacking&quot;&gt;What do we need to keep hacking?&lt;/h2&gt;
&lt;p&gt;Brought up by Gabor&lt;/p&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;money&quot; class=&quot;item&quot;&gt;Money&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;We do much volunteer work, but when we get funding, we can devote more time to
hacking&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;travel_conferences&quot; class=&quot;item&quot;&gt;Travel/Conferences&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;We'd like to get together a few times (2? 3? 4?) a year, in real life.&lt;/p&gt;
&lt;p&gt;Funding and organization would be very welcome&lt;/p&gt;
&lt;/dd&gt;
&lt;dt&gt;&lt;strong&gt;&lt;a name=&quot;short_time_funding&quot; class=&quot;item&quot;&gt;Short-time funding&lt;/a&gt;&lt;/strong&gt;&lt;/dt&gt;

&lt;dd&gt;
&lt;p&gt;It would be nice to have a way to have funding available much more quickly
than through the usual grant process, which tends to be longish.&lt;/p&gt;
&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;h2 id=&quot;rakudo_star_feedback&quot;&gt;Rakudo Star feedback&lt;/h2&gt;
&lt;p&gt;Good: It worked. It did what we wanted it to.&lt;/p&gt;
&lt;p&gt;Bad:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;It lacked a module installer (It shipped proto, but didn't install it).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Compilation takes too much memory. pmichaud will try a hack to split the
setting, which would solve that problem.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;There was some discussion about the roles + outer scopes bugs, which was way
over my head. It seems to be related to the fact that parrot has two outer
chains for nested blocks: one at compile time, one at runtime. Since role
methods are flattened into classes, there compile time outer block is actually
different than where it runs, and that  screws up ... forget it, somebody else must describe it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lack of modules - doesn't seem to bee a big problem&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Lack of features: not a big problem.&lt;/p&gt;
&lt;p&gt;Biggest complaints: missing perl6doc. Missing non-blocking IO, binary file
support.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Prefix paths with spaces are not supported :(&lt;/p&gt;
&lt;p&gt;jnthn: &amp;quot;I actually tried to write a C program that binary patches the perl6
executable to allow spaces in path names. It almost worked.&amp;quot;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;We will try to advocate compilation to PBC, not PIR - once that's supported.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;proto_pls&quot;&gt;Proto/Pls&lt;/h2&gt;
&lt;p&gt;Proto needs to be end-of-life'd.&lt;/p&gt;
&lt;p&gt;It confuses people that there are two different project lists, and the lists
diverge.&lt;/p&gt;
&lt;p&gt;We would like to decentralize the module list somehow. Still open how.&lt;/p&gt;

&lt;p&gt;People don't release Perl 6 modules, because there's no need so far, and
it's tedious to add the version name in each .pm/.pm6 file. We might need to
come up with a clever idea for that.&lt;/p&gt;

&lt;h2 id=&quot;backend_diversity&quot;&gt;Backend diversity&lt;/h2&gt;
&lt;p&gt;Additionally to the parrot backend, we want to run Perl 6 code on other
virtual machines.&lt;/p&gt;
&lt;p&gt;jnthn will work on a .NET/CLR port. He wants to prototype the new low-level
class composition code in .NET anyway, which will provide the basic
foundations for running NQP.&lt;/p&gt;
&lt;p&gt;pmichaud wants to explore javascript on V8 as a possible backend. &amp;quot;I managed
PIR, I'll certainly manage javascript&amp;quot; :-)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Huge time sink, but still worth doing it&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Apache runtime library might be worth looking into&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;risks: stalled refactors are dangerous (see: PHP 6, cardinal (the
ruby-on-parrot compiler))&lt;/p&gt;
&lt;p&gt;We want to avoid fragmentation into many subprojects&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;We want to increase the number of possible contributors to rakudo by
enabling non-parrot people to contribute.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Code for different backends will be maintained as directories in Rakudo and
NQP, not as branches.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;pir:: things will be hidden behind an nqp:: abstraction layer&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;attracting_contributors&quot;&gt;Attracting contributors&lt;/h2&gt;
&lt;p&gt;Moritz wants to continue with the &amp;quot;weekly&amp;quot; challenges, but runs out of ideas.
Add ideas to &lt;a href=&quot;http://svn.pugscode.org/pugs/misc/helpnow/README&quot;&gt;http://svn.pugscode.org/pugs/misc/helpnow/README&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We will try to apply patches faster, thus encouraging people who already did
the first step.&lt;/p&gt;

&lt;h2 id=&quot;documentation&quot;&gt;Documentation&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;in p5 pod for now, so that people can contribute easily&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;masak and szabgab expressed interest in working on pod6 tools&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

 
</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/my-first-yapc.html">
 <title>My first YAPC - YAPC::EU 2010 in Pisa</title>
  <link>http://perlgeek.de/blog-en/perl-6/my-first-yapc.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Fri, Aug  6 16:37:07 2010</pubDate>
    <description>&lt;!-- 1281105427 --&gt;

&lt;p&gt;This week I attended my first international Perl conference, the &lt;a
href=&quot;http://conferences.yapceurope.org/ye2010/index.html&quot;&gt;YAPC::EU 2010 in
Pisa, Italy&lt;/a&gt;. I very much enjoyed it.&lt;/p&gt;

&lt;p&gt;I arrived a few days earlier, and spent the time visiting Pisa, talking
with old and new friends, and did some collaborative hacking. I especially
enjoyed meeting people with whom I had had only contact via Internet so far,
and found all of them to be very nice in meat space.&lt;/p&gt;

&lt;p&gt;On Tuesday, the day before the conference started officially, a group of
Perl 6 hackers met and discussed topics around Perl 6 and Rakudo. I recall
talking with Patrick Michaud, Jonathan Worthington, Carl Mäsak, Paweł
Murias, Gabor Szabo, smash (I can't spell his full name correctly from memory,
sorry for that), and we have a very productive discussion (about 5 hours or
so). Notes from the discussion will be published later.&lt;/p&gt;

&lt;p&gt;On Wednesday the actual conference started, and there were plenty of very
interesting talks, and very amusing lightning talks. I generally like the
humor that is widespread in the Perl community.&lt;/p&gt;

&lt;p&gt;On Thursday I continued to attend nice and informative talks, and also gave
a talk on my own. It was about physical modelling with Perl 6, and in general
the feedback was very positive, and somebody even commented that while he
didn't understand everything I wrote, it reminded him that it was important to
learn Perl 6 now. Win \o/. (There was also some criticism, but from somebody
who apparently hasn't read &lt;a
href=&quot;http://conferences.yapceurope.org/ye2010/talk/2949&quot;&gt;the abstract&lt;/a&gt;;
the &quot;write-only&quot; meme seems to apply to perl bloggers, not code). You can find
&lt;a href=&quot;http://perlgeek.de/talks/2010/yapceu-p6-realworld/&quot;&gt;the slides
to my talk here.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Firday was the day of my departure too - sadly I had to leave after the
first talk, and missed the rest of the day, including the closing keynote by
mst (I did attend a talk of his) and the traditional auction.&lt;/p&gt;

&lt;p&gt;I especially enjoyed...&lt;/p&gt;

&lt;ul&gt;
    &lt;li&gt;meeting Patrick, Larry, Gloria, Aaron, Gabor and many others for the
    first time in real-life&lt;/li&gt;
    &lt;li&gt;a thorough, high-bandwith discussion with Larry, Jonathan, Patrick and
    Carl about p6 spec questions, and the Perl 6 discussions mentioned
    earlier&lt;/li&gt;
    &lt;li&gt;a lightning talk &lt;em&gt;imagine you're in a data center with no
    connection to the outside, and you accidentally executed &lt;code&gt;chmod -x
    chmod&lt;/code&gt;. What would you do?&lt;/em&gt;&lt;/li&gt;
    &lt;li&gt;good Italian Pizzas (although I had to wait 50 minutes for one of
    them)&lt;/li&gt;
&lt;!--    &lt;li&gt;discovering that the cable connection in the hotel did not block
TCP port 53&lt;/li&gt; --&gt;
    &lt;li&gt;A talk by Tim Bunce, where he demonstrated database access in Perl 6
    both with libraries that do native calls, and through the Blizkost project
    using the Perl 5 DBI/DBD::SQLite modules&lt;/li&gt;
    &lt;li&gt;the general relaxed attitude in the Perl community, where people help
    each other, and don't seem to be easily offended (at least in meat space
    :)&lt;/li&gt;
    &lt;li&gt;being surrounded by many other geeks&lt;/li&gt;
    &lt;li&gt;realizing that several Perl hackers brought their family to the
    conference&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It was an overwhelming experience, and I look forward to my next YAPC!&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-5-to-6/28-currying.html">
 <title>Currying</title>
  <link>http://perlgeek.de/blog-en/perl-5-to-6/28-currying.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Sun, Jul 25 11:17:10 2010</pubDate>
    <description>&lt;!-- 1280049430 --&gt;

&lt;h3&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;NAME&quot;
&gt;NAME&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&amp;#34;Perl 5 to 6&amp;#34; Lesson 28 - Currying&lt;/p&gt;

&lt;h3&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;SYNOPSIS&quot;
&gt;SYNOPSIS&lt;/a&gt;&lt;/h3&gt;

&lt;pre&gt;  use v6;
  
  my &amp;#38;f := &amp;#38;substr.assuming(&amp;#39;Hello, World&amp;#39;);
  say f(0, 2);                # He
  say f(3, 2);                # lo
  say f(7);                   # World
  
  say &amp;#60;a b c&amp;#62;.map: * x 2;     # aabbcc
  say &amp;#60;a b c&amp;#62;.map: *.uc;      # ABC
  for ^10 {
      print &amp;#60;R G B&amp;#62;.[$_ % *]; # RGBRGBRGBR
  }&lt;/pre&gt;

&lt;h3&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;DESCRIPTION&quot;
&gt;DESCRIPTION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&lt;i&gt;Currying&lt;/i&gt; or &lt;i&gt;partial application&lt;/i&gt; is the process of generating a function from another function or method by providing only some of the arguments. This is useful for saving typing, and when you want to pass a callback to another function.&lt;/p&gt;

&lt;p&gt;Suppose you want a function that lets you extract substrings from &lt;code&gt;&amp;#34;Hello, World&amp;#34;&lt;/code&gt; easily. The classical way of doing that is writing your own function:&lt;/p&gt;

&lt;pre&gt;  sub f(*@a) {
      substr(&amp;#39;Hello, World&amp;#39;, |@a)
  }&lt;/pre&gt;

&lt;h4&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;Currying_with_assuming&quot;
&gt;Currying with &lt;code&gt;assuming&lt;/code&gt;&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Perl 6 provides a method &lt;code&gt;assuming&lt;/code&gt; on code objects, which applies the arguments passed to it to the invocant, and returns the partially applied function.&lt;/p&gt;

&lt;pre&gt;  my &amp;#38;f := &amp;#38;substr.assuming(&amp;#39;Hello, World&amp;#39;);&lt;/pre&gt;

&lt;p&gt;Now &lt;code&gt;f(1, 2)&lt;/code&gt; is the same as &lt;code&gt;substr(&amp;#39;Hello, World&amp;#39;, 1, 2)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;assuming&lt;/code&gt; also works on operators, because operators are just subroutines with weird names. To get a subroutine that adds 2 to whatever number gets passed to it, you could write&lt;/p&gt;

&lt;pre&gt;  my &amp;#38;add_two := &amp;#38;infix:&amp;#60;+&amp;#62;.assuming(2);&lt;/pre&gt;

&lt;p&gt;But that&amp;#39;s tedious to write, so there&amp;#39;s another option.&lt;/p&gt;

&lt;h4&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;Currying_with_the_Whatever-Star&quot;
&gt;Currying with the Whatever-Star&lt;/a&gt;&lt;/h4&gt;

&lt;pre&gt;  my &amp;#38;add_two := * + 2;
  say add_two(4);         # 6&lt;/pre&gt;

&lt;p&gt;The asterisk, called &lt;i&gt;Whatever&lt;/i&gt;, is a placeholder for an argument, so the whole expression returns a closure. Multiple Whatevers are allowed in a single expression, and create a closure that expects more arguments, by replacing each term &lt;code&gt;*&lt;/code&gt; by a formal parameter. So &lt;code&gt;* * 5 + *&lt;/code&gt; is equivalent to &lt;code&gt;-&amp;#62; $a, $b { $a * 5 + $b }&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;  my $c = * * 5 + *;
  say $c(10, 2);                # 52&lt;/pre&gt;

&lt;p&gt;Note that the second &lt;code&gt;*&lt;/code&gt; is an infix operator, not a term, so it is not subject to Whatever-currying.&lt;/p&gt;

&lt;p&gt;The process of lifting an expression with Whatever stars into a closure is driven by syntax, and done at compile time. This means that&lt;/p&gt;

&lt;pre&gt;  my $star = *;
  my $code = $star + 2&lt;/pre&gt;

&lt;p&gt;does not construct a closure, but instead dies with a message like&lt;/p&gt;

&lt;pre&gt;  Can&amp;#39;t take numeric value for object of type Whatever&lt;/pre&gt;

&lt;p&gt;Whatever currying is more versatile than &lt;code&gt;.assuming&lt;/code&gt;, because it allows to curry something else than the first argument very easily:&lt;/p&gt;

&lt;pre&gt;  say  ~(1, 3).map: &amp;#39;hi&amp;#39; x *    # hi hihihi&lt;/pre&gt;

&lt;p&gt;This curries the second argument of the string repetition operator infix &lt;code&gt;x&lt;/code&gt;, so it returns a closure that, when called with a numeric argument, produces the string &lt;code&gt;hi&lt;/code&gt; as often as that argument specifies.&lt;/p&gt;

&lt;p&gt;The invocant of a method call can also be Whatever star, so&lt;/p&gt;

&lt;pre&gt;  say &amp;#60;a b c&amp;#62;.map: *.uc;      # ABC&lt;/pre&gt;

&lt;p&gt;involves a closure that calls the &lt;code&gt;uc&lt;/code&gt; method on its argument.&lt;/p&gt;

&lt;h3&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;MOTIVATION&quot;
&gt;MOTIVATION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Perl 5 could be used for functional programming, which has been demonstrated in Mark Jason Dominus&amp;#39; book &lt;i&gt;Higher Order Perl&lt;/i&gt;.&lt;/p&gt;

&lt;p&gt;Perl 6 strives to make it even easier, and thus provides tools to make typical constructs in functional programming easily available. Currying and easy construction of closures is a key to functional programming, and makes it very easy to write transformation for your data, for example together with &lt;code&gt;map&lt;/code&gt; or &lt;code&gt;grep&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;SEE_ALSO&quot;
&gt;SEE ALSO&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://perlcabal.org/syn/S02.html#Built-In_Data_Types&quot; class=&quot;podlinkurl&quot;
&gt;http://perlcabal.org/syn/S02.html#Built-In_Data_Types&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://hop.perl.plover.com/&quot; class=&quot;podlinkurl&quot;
&gt;http://hop.perl.plover.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Currying&quot; class=&quot;podlinkurl&quot;
&gt;http://en.wikipedia.org/wiki/Currying&lt;/a&gt;&lt;/p&gt;

 </description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-5-to-6/27-common-idioms.html">
 <title>Common Perl 6 data processing idioms</title>
  <link>http://perlgeek.de/blog-en/perl-5-to-6/27-common-idioms.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Thu, Jul 22 15:34:26 2010</pubDate>
    <description>&lt;!-- 1279805666 --&gt;

&lt;h3&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;NAME&quot;
&gt;NAME&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;&amp;#34;Perl 5 to 6&amp;#34; Lesson 27 - Common Perl 6 data processing idioms&lt;/p&gt;

&lt;h3&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;SYNOPSIS&quot;
&gt;SYNOPSIS&lt;/a&gt;&lt;/h3&gt;

&lt;pre&gt;  # create a hash from a list of keys and values:
  # solution 1: slices
  my %hash; %hash{@keys} = @values;
  # solution 2: meta operators
  my %hash = @keys Z=&amp;#62; @values;

  # create a hash from an array, with
  # true value for each array item:
  my %exists = @keys Z=&amp;#62; 1 xx *;

  # limit a value to a given range, here 0..10.
  my $x = -2;
  say 0 max $x min 10;

  # for debugging: dump the contents of a variable,
  # including its name, to STDERR
  note :$x.perl;

  # sort case-insensitively
  say @list.sort: *.lc;

  # mandatory attributes
  class Something {
      has $.required = die &amp;#34;Attribute &amp;#39;required&amp;#39; is mandatory&amp;#34;;
  }
  Something.new(required =&amp;#62; 2); # no error
  Something.new()               # BOOM&lt;/pre&gt;

&lt;h3&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;DESCRIPTION&quot;
&gt;DESCRIPTION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Learning the specification of a language is not enough to be productive with it. Rather you need to know how to solve specific problems. Common usage patterns, called &lt;i&gt;idioms&lt;/i&gt;, helps you not having to re-invent the wheel every time you&amp;#39;re faced with a problem.&lt;/p&gt;

&lt;p&gt;So here a some common Perl 6 idioms, dealing with data structures.&lt;/p&gt;

&lt;h4&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;Hashes&quot;
&gt;Hashes&lt;/a&gt;&lt;/h4&gt;

&lt;pre&gt;  # create a hash from a list of keys and values:
  # solution 1: slices
  my %hash; %hash{@keys} = @values;
  # solution 2: meta operators
  my %hash = @keys Z=&amp;#62; @values;&lt;/pre&gt;

&lt;p&gt;The first solution is the same you&amp;#39;d use in Perl 5: assignment to a slice. The second solution uses the zip operator &lt;code&gt;Z&lt;/code&gt;, which joins to list like a zip fastener: &lt;code&gt;1, 2, 3 Z 10, 20, 30&lt;/code&gt; is &lt;code&gt;1, 10, 2, 20, 3, 30&lt;/code&gt;. The &lt;code&gt;Z=&amp;#62;&lt;/code&gt; is a meta operator, which combines zip with &lt;code&gt;=&amp;#62;&lt;/code&gt; (the Pair construction operator). So &lt;code&gt;1, 2, 3 Z=&amp;#62; 10, 20, 30&lt;/code&gt; evaluates to &lt;code&gt;1 =&amp;#62; 10, 2 =&amp;#62; 20, 3 =&amp;#62; 30&lt;/code&gt;. Assignment to a hash variable turns that into a Hash.&lt;/p&gt;

&lt;p&gt;For existence checks, the values in a hash often doesn&amp;#39;t matter, as long as they all evaluate to &lt;code&gt;True&lt;/code&gt; in boolean context. In that case, a nice way to initialize the hash from a given array or list of keys is&lt;/p&gt;

&lt;pre&gt;  my %exists = @keys Z=&amp;#62; 1 xx *;&lt;/pre&gt;

&lt;p&gt;which uses a lazy, infinite list of 1s on the right-hand side, and relies on the fact that &lt;code&gt;Z&lt;/code&gt; ends when the shorter list is exhausted.&lt;/p&gt;

&lt;h4&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;Numbers&quot;
&gt;Numbers&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Sometimes you want to get a number from somewhere, but clip it into a predefined range (for example so that it can act as an array index).&lt;/p&gt;

&lt;p&gt;In Perl 5 you often end up with things like &lt;code&gt;$a = $b &amp;#62; $upper ? $upper : $b&lt;/code&gt;, and another conditional for the lower limit. With the &lt;code&gt;max&lt;/code&gt; and &lt;code&gt;min&lt;/code&gt; infix operators, that simplifies considerably to&lt;/p&gt;

&lt;pre&gt;  my $in-range = $lower max $x min $upper;&lt;/pre&gt;

&lt;p&gt;because &lt;code&gt;$lower max $x&lt;/code&gt; returns the larger of the two numbers, and thus clipping to the lower end of the range.&lt;/p&gt;

&lt;p&gt;Since &lt;code&gt;min&lt;/code&gt; and &lt;code&gt;max&lt;/code&gt; are infix operators, you can also clip infix:&lt;/p&gt;

&lt;pre&gt; $x max= 0;
 $x min= 10;&lt;/pre&gt;

&lt;h4&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;Debugging&quot;
&gt;Debugging&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Perl 5 has Data::Dumper, Perl 6 objects have the &lt;code&gt;.perl&lt;/code&gt; method. Both generate code that reproduces the original data structure as faithfully as possible.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;:$var&lt;/code&gt; generates a Pair (&amp;#34;colonpair&amp;#34;), using the variable name as key (but with sigil stripped). So it&amp;#39;s the same as &lt;code&gt;var =&amp;#62; $var&lt;/code&gt;. &lt;code&gt;note()&lt;/code&gt; writes to the standard error stream, appending a newline. So &lt;code&gt;note :$var.perl&lt;/code&gt; is quick way of obtaining the value of a variable for debugging; purposes, along with its name.&lt;/p&gt;

&lt;h4&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;Sorting&quot;
&gt;Sorting&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;Like in Perl 5, the &lt;code&gt;sort&lt;/code&gt; built-in can take a function that compares two values, and then sorts according to that comparison. Unlike Perl 5, it&amp;#39;s a bit smarter, and automatically does a transformation for you if the function takes only one argument.&lt;/p&gt;

&lt;p&gt;In general, if you want to compare by a transformed value, in Perl 5 you can do:&lt;/p&gt;

&lt;pre&gt;    # WARNING: Perl 5 code ahead
    my @sorted = sort { transform($a) cmp transform($b) } @values;

    # or the so-called Schwartzian Transform:
    my @sorted = map { $_-&amp;#62;[1] }
                 sort { $a-&amp;#62;[0] cmp $b-&amp;#62;[0] }
                 map { [transform($_), $_] }
                 @values&lt;/pre&gt;

&lt;p&gt;The former solution requires repetitive typing of the transformation, and executes it for each comparison. The second solution avoids that by storing the transformed value along with the original value, but it&amp;#39;s quite a bit of code to write.&lt;/p&gt;

&lt;p&gt;Perl 6 automates the second solution (and a bit more efficient than the naiive Schwartzian transform, by avoiding an array for each value) when the transformation function has arity one, ie accepts one argument only:&lt;/p&gt;

&lt;pre&gt;    my @sorted = sort &amp;#38;transform, @values;&lt;/pre&gt;

&lt;h4&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;Mandatory_Attributes&quot;
&gt;Mandatory Attributes&lt;/a&gt;&lt;/h4&gt;

&lt;p&gt;The typical way to enforce the presence of an attribute is to check its presence in the constructor - or in all constructors, if there are many.&lt;/p&gt;

&lt;p&gt;That works in Perl 6 too, but it&amp;#39;s easier and safer to require the presence at the level of each attribute:&lt;/p&gt;

&lt;pre&gt;    has $.attr = die &amp;#34;&amp;#39;attr&amp;#39; is mandatory&amp;#34;;&lt;/pre&gt;

&lt;p&gt;This exploits the default value mechanism. When a value is supplied, the code for generating the default value is never executed, and the &lt;code&gt;die&lt;/code&gt; never triggers. If any constructor fails to set it, an exception is thrown.&lt;/p&gt;

&lt;h3&gt;&lt;a class='u' href='#___top' title='click to go to top of document'
name=&quot;MOTIVATION&quot;
&gt;MOTIVATION&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;N/A&lt;/p&gt;

 </description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/gabor-keep-going.html">
 <title>Gabor: Keep going</title>
  <link>http://perlgeek.de/blog-en/perl-6/gabor-keep-going.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Mon, Jul 19 22:36:05 2010</pubDate>
    <description>&lt;!-- 1279571765 --&gt;

&lt;p&gt;After reading &lt;a
href=&quot;http://blogs.perl.org/users/gabor_szabo/2010/07/promoting-perl-is-fun.html&quot;&gt;this
blog post&lt;/a&gt;, I just want to say: keep going.&lt;/p&gt;

&lt;p&gt;Gabor does really awesome things for Perl (and especially for Perl 6, which
I tend to notice more): beginner's tutorials, screencasts, training courses,
writes an IDE and so on. If his primary interest was his own success, his
priorities would be quite different.&lt;/p&gt;

&lt;p&gt;I hope that Gabor doesn't pay too much attention to the hostilities from
parts of the Perl community, and I wish him and us all the best for his &lt;a
href=&quot;http://news.perlfoundation.org/2010/06/hague-grant-application-perl-e.html&quot;&gt;current
project&lt;/a&gt;.&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/contribute-now-hash-pick.html">
 <title>This Week's Contribution to Perl 6 Week 9: Implement Hash.pick for Rakudo</title>
  <link>http://perlgeek.de/blog-en/perl-6/contribute-now-hash-pick.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Tue, Jul 13 15:22:47 2010</pubDate>
    <description>&lt;!-- 1279027367 --&gt;

&lt;p&gt;For this week's contribution to Perl 6 we ask you to implement the
&lt;code&gt;Hash.pick&lt;/code&gt; method (which does a weighted random selection) for
Rakudo.&lt;/p&gt;

&lt;p&gt;(&lt;a
    href=&quot;http://perlgeek.de/blog-en/perl-6/contribute-now-announce.html&quot;&gt;Introduction
    to this series of challenges&lt;/a&gt;)&lt;/p&gt;

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

&lt;p&gt;In Perl 6 the &lt;code&gt;List&lt;/code&gt; class has a method called &lt;code&gt;pick&lt;/code&gt;,
which randomly selects one item from a list. It has a few more options
too:&lt;/p&gt;

&lt;pre&gt;
&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;synIdentifier&quot;&gt;pick&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;       &lt;span class=&quot;synComment&quot;&gt;# pick one random element&lt;/span&gt;
&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;synIdentifier&quot;&gt;pick&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;synComment&quot;&gt;# pick two distinct, random elements&lt;/span&gt;
&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;synIdentifier&quot;&gt;pick&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;synStatement&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;replace&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;synComment&quot;&gt;# pick two random elements, it's ok&lt;/span&gt;
                           &lt;span class=&quot;synComment&quot;&gt;# if they are the same&lt;/span&gt;
&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;synIdentifier&quot;&gt;pick&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;synComment&quot;&gt;# return a random permutation of the elements&lt;/span&gt;
&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;synIdentifier&quot;&gt;pick&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;synConstant&quot;&gt;replace&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;synComment&quot;&gt;# infinite, random stream of elements&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;This is already &lt;a
href=&quot;http://github.com/rakudo/rakudo/blob/master/src/core/Any-list.pm#L165&quot;&gt;implemented
through several multi methods in Rakudo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now the specification &lt;a
href=&quot;http://perlcabal.org/syn/S32/Containers.html#Bag&quot;&gt;describes such a
method for hashes too&lt;/a&gt; (actually it talks about Bags, but Rakudo doesn't
have Bags yet. Pretend it says &quot;Hash&quot; instead). It assumes that each value in
the hash is numeric, and that the value is a weight that determines the
probability of picking one value. For example&lt;/p&gt;

&lt;pre&gt;
{&lt;span class=&quot;synConstant&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;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;b&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;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;synIdentifier&quot;&gt;pick&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;synComment&quot;&gt;# returns 'a' with probability 1/3&lt;/span&gt;
                        &lt;span class=&quot;synComment&quot;&gt;# and 'b' with probability 2/3&lt;/span&gt;

{&lt;span class=&quot;synConstant&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;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;b&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;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;synIdentifier&quot;&gt;pick&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;synComment&quot;&gt;# &amp;lt;a b b&amp;gt; with probability 1/3&lt;/span&gt;
                           &lt;span class=&quot;synComment&quot;&gt;# &amp;lt;b a b&amp;gt; with probability 1/3&lt;/span&gt;
                           &lt;span class=&quot;synComment&quot;&gt;# &amp;lt;b b a&amp;gt; with probability 1/3&lt;/span&gt;
{&lt;span class=&quot;synConstant&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;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;b&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;0.5&lt;/span&gt;}&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;pick&lt;/span&gt;(&lt;span class=&quot;synStatement&quot;&gt;*&lt;/span&gt;) &lt;span class=&quot;synComment&quot;&gt;# dies, because the weights aren't all integers&lt;/span&gt;
{&lt;span class=&quot;synConstant&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;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;b&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;0.5&lt;/span&gt;}&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;pick&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;synConstant&quot;&gt;replace&lt;/span&gt;)  &lt;span class=&quot;synComment&quot;&gt;# ok &lt;/span&gt;
&lt;/pre&gt;



&lt;h2&gt;What you can do&lt;/h2&gt;

&lt;p&gt;Implement Hash.pick. It's ok if your patch doesn't cover all cases. It
would be nice if it supported non-integer weights.&lt;/p&gt;

&lt;p&gt;Hint: this could be done by storing a list of accumulated weights, and a
list of keys.&lt;/p&gt;

&lt;pre&gt;
{&lt;span class=&quot;synConstant&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;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;b&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;2.5&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;c&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;1&lt;/span&gt;}

&lt;span class=&quot;synComment&quot;&gt;# could translate to &lt;/span&gt;
&lt;span class=&quot;synSpecial&quot;&gt;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@keys&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;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;,&lt;/span&gt; &lt;span class=&quot;synSpecial&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;synConstant&quot;&gt;c&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;my&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;@accumulated_weights&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;3.5&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;synConstant&quot;&gt;4.5&lt;/span&gt;)&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;synComment&quot;&gt;# now pick a random number between 0 and 4.5,&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;# find the next-highest index in @accumulated_weights&lt;/span&gt;
&lt;span class=&quot;synComment&quot;&gt;# with a binary search, and then use that to obtain the key.&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;Of course other schemes are fine too.&lt;/p&gt;

&lt;p&gt;Second hint: because it takes quite some time to recompile Rakudo, it is 
probably easier to implement the actual logic in a function
in a normal source file first, and only later move it into src/core/Hash.pm.&lt;/p&gt;

&lt;h2&gt;Submission&lt;/h2&gt;

&lt;p&gt;Please submit your source code to the &lt;a
href=&quot;mailto:perl6-compiler@perl.org&quot;&gt;perl6-compiler@perl.org&lt;/a&gt; mailing
list (and put moritz@faui2k3.org on CC,
because the mailing list sometimes lack quite a bit).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; there's one submission on the perl6-compiler
mailing list already, which looks pretty good.&lt;/p&gt;



</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/want-to-write-shiny-graphics.html">
 <title>Want to write shiny SVG graphics with Perl 6? Port Scruffy!</title>
  <link>http://perlgeek.de/blog-en/perl-6/want-to-write-shiny-graphics.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Mon, Jul 12 15:43:27 2010</pubDate>
    <description>&lt;!-- 1278942207 --&gt;

&lt;p&gt;First let my apologize for waiting so long to come up with a new 
&lt;a href=&quot;http://perlgeek.de/blog-en/perl-6/contribute-now-announce.html&quot;&gt;&quot;weekly&quot;
    Perl 6 challenge&lt;/a&gt; - I'm running out of ideas, and the one I have left needs
more time to prepare.&lt;/p&gt;

&lt;p&gt;Instead I want to motivate you to help porting the ruby &lt;a
href=&quot;http://scruffy.rubyforge.org/&quot;&gt;scruffy charting library&lt;/a&gt; to Perl 6.
It can generate &lt;a
    href=&quot;http://replay.waybackmachine.org/20080625015853/http://scruffy.rubyforge.org/&quot;&gt;shiny
SVG graphics&lt;/a&gt; (they are currently broken on their main website, hence the
waybackmachine link).&lt;/p&gt;


&lt;p&gt;There's already an &lt;a href=&quot;http://github.com/moritz/tufte/&quot;&gt;initial
version Perl 6 port called &quot;tufte&quot;&lt;/a&gt;, but it's not running yet. It needs your
help. If you know a little ruby, and want to learn some more Perl 6, join
#perl6, ask for a commit bit, and translate some ruby code into Perl 6. And in
the end you'll be rewarded with nice SVG charts :-).&lt;/p&gt;


</description>
  </item>
  <item rdf:about="http://perlgeek.de/blog-en/perl-6/contribute-now-argfiles.html">
 <title>This Week's Contribution to Perl 6 Week 8: Implement $*ARGFILES for Rakudo</title>
  <link>http://perlgeek.de/blog-en/perl-6/contribute-now-argfiles.html</link>
 <author>Moritz Lenz</author>
   <pubDate>Tue, Jun 29 00:00:00 2010</pubDate>
    <description>&lt;!-- 1277762400 --&gt;

&lt;p&gt;For this week's contribution to Perl 6 we ask you to implement the
&lt;code&gt;$*ARGFILES&lt;/code&gt; special variable (and underlying object) for
Rakudo.&lt;/p&gt;

&lt;p&gt;(&lt;a
    href=&quot;http://perlgeek.de/blog-en/perl-6/contribute-now-announce.html&quot;&gt;Introduction
    to this series of challenges&lt;/a&gt;)&lt;/p&gt;

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

&lt;p&gt;In Perl 5, there is a &quot;magic&quot; way to iterate over input: &lt;code&gt;while (my
$line = &amp;lt;&amp;gt;) { ... }&lt;/code&gt;. This reads from standard input if no command
line arguments were provided. If there are command line arguments, they are
taken as file names, and &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt; iterates over the contents of
these files.&lt;/p&gt;

&lt;p&gt;In Perl 6 this magic is performed with the &lt;code&gt;$*ARGFILES&lt;/code&gt; special
variable. Please implement it!&lt;/p&gt;

&lt;p&gt;To do that, you have to understand how file reading works in Perl 6. Once
you have a file handle, there are two ways to read lines: either by calling
&lt;code&gt;$handle.get&lt;/code&gt;, which returns just one line, or by calling
&lt;code&gt;$handle.lines&lt;/code&gt;, which returns a (lazy) list of all the remaining
lines.&lt;/p&gt;

&lt;p&gt;You can obtain the command line arguments from &lt;code&gt;@*ARGS&lt;/code&gt;, open a
file with &lt;code&gt;my $handle = open $filename;&lt;/code&gt; for reading; And finally
you can use &lt;code&gt;lines('filename')&lt;/code&gt; to read all lines from a file.&lt;/p&gt;


&lt;h2&gt;What you can do&lt;/h2&gt;

&lt;p&gt;Implement a backend class for &lt;code&gt;$*ARGFILES&lt;/code&gt;. You can do that in
normal Perl 6 code, no need to change the actual compiler. Once that's done,
we will plug it into Rakudo. Your code might look like this:&lt;/p&gt;

&lt;pre&gt;
&lt;span class=&quot;synStatement&quot;&gt;class&lt;/span&gt; IO::ArgFiles {
    &lt;span class=&quot;synSpecial&quot;&gt;has&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;filenames&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;synStatement&quot;&gt;method&lt;/span&gt; get() { &lt;span class=&quot;synStatement&quot;&gt;...&lt;/span&gt; }
    &lt;span class=&quot;synStatement&quot;&gt;method&lt;/span&gt; &lt;span class=&quot;synIdentifier&quot;&gt;lines&lt;/span&gt;() { &lt;span class=&quot;synStatement&quot;&gt;...&lt;/span&gt; }
    &lt;span class=&quot;synStatement&quot;&gt;method&lt;/span&gt; filename() {
        &lt;span class=&quot;synComment&quot;&gt;# return the current filename, or '-' if standard input&lt;/span&gt;
        &lt;span class=&quot;synStatement&quot;&gt;...&lt;/span&gt;
    }
}
&lt;span class=&quot;synSpecial&quot;&gt;my&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;ARGFILES&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&lt;/span&gt; IO::ArgFiles&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;new&lt;/span&gt;(&lt;span class=&quot;synConstant&quot;&gt;filenames&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;=&amp;gt;&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;ARGS&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;say&lt;/span&gt; &lt;span class=&quot;synStatement&quot;&gt;for&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;ARGFILES&lt;/span&gt;&lt;span class=&quot;synStatement&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;synIdentifier&quot;&gt;lines&lt;/span&gt;()&lt;span class=&quot;synStatement&quot;&gt;;&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;(Of course this is only a rough skeleton, you might need to change some
details, or add some things).&lt;/p&gt;

&lt;h2&gt;Submission&lt;/h2&gt;

&lt;p&gt;Please submit your source code to the &lt;a
href=&quot;mailto:perl6-compiler@perl.org&quot;&gt;perl6-compiler@perl.org&lt;/a&gt; mailing
list (and put moritz@faui2k3.org on CC,
because the mailing list sometimes lack quite a bit).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;: there have been two submissions, and a mixture of
both has been applied.&lt;/p&gt;


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