<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Day 7 &#8211; Lexical variables</title>
	<atom:link href="http://perl6advent.wordpress.com/2010/12/07/day-7-lexical-variables/feed/" rel="self" type="application/rss+xml" />
	<link>http://perl6advent.wordpress.com/2010/12/07/day-7-lexical-variables/</link>
	<description>Something cool about Perl 6 every day</description>
	<lastBuildDate>Sun, 03 Feb 2013 05:15:50 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: carl</title>
		<link>http://perl6advent.wordpress.com/2010/12/07/day-7-lexical-variables/#comment-889</link>
		<dc:creator><![CDATA[carl]]></dc:creator>
		<pubDate>Fri, 13 May 2011 14:35:42 +0000</pubDate>
		<guid isPermaLink="false">http://perl6advent.wordpress.com/?p=516#comment-889</guid>
		<description><![CDATA[Oh, for sure. It&#039;s more like there&#039;s a two-fold layering here:

&lt;ul&gt;
&lt;li&gt;Lexical variables can do the closures trick. Package variables can&#039;t.&lt;/li&gt;
&lt;li&gt;Perl 5&#039;s default is package variables. We know lexical variables to be the better default, but we&#039;re bound by backwards compatibility in Perl 5. In Perl 6, the default is lexical variables.&lt;/li&gt;
&lt;/ul&gt;

So, it&#039;s not that Perl 6 beats Perl 5 in terms of features; they&#039;re equally powerful in this regard. But Perl 6 has the saner default.]]></description>
		<content:encoded><![CDATA[<p>Oh, for sure. It&#8217;s more like there&#8217;s a two-fold layering here:</p>
<ul>
<li>Lexical variables can do the closures trick. Package variables can&#8217;t.</li>
<li>Perl 5&#8242;s default is package variables. We know lexical variables to be the better default, but we&#8217;re bound by backwards compatibility in Perl 5. In Perl 6, the default is lexical variables.</li>
</ul>
<p>So, it&#8217;s not that Perl 6 beats Perl 5 in terms of features; they&#8217;re equally powerful in this regard. But Perl 6 has the saner default.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bessarabov</title>
		<link>http://perl6advent.wordpress.com/2010/12/07/day-7-lexical-variables/#comment-888</link>
		<dc:creator><![CDATA[bessarabov]]></dc:creator>
		<pubDate>Fri, 13 May 2011 11:58:52 +0000</pubDate>
		<guid isPermaLink="false">http://perl6advent.wordpress.com/?p=516#comment-888</guid>
		<description><![CDATA[To be honest perl5 can do the same trick:


#!/usr/bin/perl

use 5.010_000;

sub counter {
    my ($count) = @_; 
    return sub { $count++ };
}

my $c1 = counter(5);
say $c1-&gt;();   # 5 
say $c1-&gt;();   # 6 

my $c2 = counter(42);
say $c2-&gt;();   # 42
say $c2-&gt;();   # 43]]></description>
		<content:encoded><![CDATA[<p>To be honest perl5 can do the same trick:</p>
<p>#!/usr/bin/perl</p>
<p>use 5.010_000;</p>
<p>sub counter {<br />
    my ($count) = @_;<br />
    return sub { $count++ };<br />
}</p>
<p>my $c1 = counter(5);<br />
say $c1-&gt;();   # 5<br />
say $c1-&gt;();   # 6 </p>
<p>my $c2 = counter(42);<br />
say $c2-&gt;();   # 42<br />
say $c2-&gt;();   # 43</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carl</title>
		<link>http://perl6advent.wordpress.com/2010/12/07/day-7-lexical-variables/#comment-459</link>
		<dc:creator><![CDATA[carl]]></dc:creator>
		<pubDate>Wed, 08 Dec 2010 15:23:49 +0000</pubDate>
		<guid isPermaLink="false">http://perl6advent.wordpress.com/?p=516#comment-459</guid>
		<description><![CDATA[Dear commenter, you are absolutely correct. I&#039;ve now changed all occurrences of &lt;code&gt;$a&lt;/code&gt; in the post to &lt;code&gt;$var&lt;/code&gt;.

I thought about mentioning in the post an occasion a few years ago at which I thought I had found a really serious bug in perl. In analyzing it, I applied all the techniques i use with Perl 6 of reducing the problem to a one-liner to isolate and identify the problem. At the end, I was left with a call to &lt;a href=&quot;http://perldoc.perl.org/functions/sort.html&quot; rel=&quot;nofollow&quot;&gt;&lt;code&gt;&amp;sort&lt;/code&gt;&lt;/a&gt; and one more use of &lt;code&gt;$a&lt;/code&gt;. And I went &quot;oh&quot; and remembered the exception about &lt;code&gt;$a&lt;/code&gt; and &lt;code&gt;$b&lt;/code&gt;.

The package-globalness of &lt;code&gt;$a&lt;/code&gt; and &lt;code&gt;$b&lt;/code&gt; is understandable from a historical perspective &#8212; &lt;code&gt;$a&lt;/code&gt; and &lt;code&gt;$b&lt;/code&gt; were used in &lt;code&gt;&amp;sort&lt;/code&gt; as package globals before lexical scoping was introduced &#8212; but it&#039;s one of the things that Perl 5 got wrong and can&#039;t back-compat itself out of. Perl 6 fixes the whole problem without much fanfare.]]></description>
		<content:encoded><![CDATA[<p>Dear commenter, you are absolutely correct. I&#8217;ve now changed all occurrences of <code>$a</code> in the post to <code>$var</code>.</p>
<p>I thought about mentioning in the post an occasion a few years ago at which I thought I had found a really serious bug in perl. In analyzing it, I applied all the techniques i use with Perl 6 of reducing the problem to a one-liner to isolate and identify the problem. At the end, I was left with a call to <a href="http://perldoc.perl.org/functions/sort.html" rel="nofollow"><code>&amp;sort</code></a> and one more use of <code>$a</code>. And I went &#8220;oh&#8221; and remembered the exception about <code>$a</code> and <code>$b</code>.</p>
<p>The package-globalness of <code>$a</code> and <code>$b</code> is understandable from a historical perspective &mdash; <code>$a</code> and <code>$b</code> were used in <code>&amp;sort</code> as package globals before lexical scoping was introduced &mdash; but it&#8217;s one of the things that Perl 5 got wrong and can&#8217;t back-compat itself out of. Perl 6 fixes the whole problem without much fanfare.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://perl6advent.wordpress.com/2010/12/07/day-7-lexical-variables/#comment-455</link>
		<dc:creator><![CDATA[Brian]]></dc:creator>
		<pubDate>Wed, 08 Dec 2010 02:00:05 +0000</pubDate>
		<guid isPermaLink="false">http://perl6advent.wordpress.com/?p=516#comment-455</guid>
		<description><![CDATA[It&#039;d be best if you avoided the variable $a , by the way, in the example; in perl5, $a and $b are specially handled, so &#039;use strict&#039; won&#039;t help a bit with them.]]></description>
		<content:encoded><![CDATA[<p>It&#8217;d be best if you avoided the variable $a , by the way, in the example; in perl5, $a and $b are specially handled, so &#8216;use strict&#8217; won&#8217;t help a bit with them.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
