<?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/"
		>
<channel>
	<title>Comments on: Syntactic sugar will occassionally kick your puppies.</title>
	<atom:link href="http://www.coffeepowered.net/2009/03/02/syntactic-sugar-will-occassionally-kick-your-puppies/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.coffeepowered.net/2009/03/02/syntactic-sugar-will-occassionally-kick-your-puppies/</link>
	<description>code and content</description>
	<lastBuildDate>Tue, 12 Jan 2010 03:36:39 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: draegtun</title>
		<link>http://www.coffeepowered.net/2009/03/02/syntactic-sugar-will-occassionally-kick-your-puppies/comment-page-1/#comment-135</link>
		<dc:creator>draegtun</dc:creator>
		<pubDate>Wed, 04 Mar 2009 13:01:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.coffeepowered.net/?p=133#comment-135</guid>
		<description>Trailing if/unless statements come from Perl and these same problems are well known there when it comes to declaring variables ;-)

However this does allow declaration of state variables....

  my $persist if 0;

This peculiarity can now be replaced in Perl 5.10 with the much nicer...

  state $persist;

&quot;Perl Best Practises&quot; only recommends u use them with next, last &amp; redo (and in fact not use &quot;unless&quot; at all!).   I don&#039;t go that far but I certainly make sure I never use variable declaration with them!

/I3az/</description>
		<content:encoded><![CDATA[<p>Trailing if/unless statements come from Perl and these same problems are well known there when it comes to declaring variables ;-)</p>
<p>However this does allow declaration of state variables&#8230;.</p>
<p>  my $persist if 0;</p>
<p>This peculiarity can now be replaced in Perl 5.10 with the much nicer&#8230;</p>
<p>  state $persist;</p>
<p>&#8220;Perl Best Practises&#8221; only recommends u use them with next, last &amp; redo (and in fact not use &#8220;unless&#8221; at all!).   I don&#8217;t go that far but I certainly make sure I never use variable declaration with them!</p>
<p>/I3az/</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Heald</title>
		<link>http://www.coffeepowered.net/2009/03/02/syntactic-sugar-will-occassionally-kick-your-puppies/comment-page-1/#comment-133</link>
		<dc:creator>Chris Heald</dc:creator>
		<pubDate>Tue, 03 Mar 2009 22:20:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.coffeepowered.net/?p=133#comment-133</guid>
		<description>The more I think about it, the less convinced I am that a more idiomatic solution exists, because anything that does a left-hand assignment is going to initialize the variable to be assigned to before the right-hand side of the expression is evaluated.

The only way I could see this working would be if there were some kind of right-hand assignment operator in ruby, which I&#039;m fairly certain there isn&#039;t.</description>
		<content:encoded><![CDATA[<p>The more I think about it, the less convinced I am that a more idiomatic solution exists, because anything that does a left-hand assignment is going to initialize the variable to be assigned to before the right-hand side of the expression is evaluated.</p>
<p>The only way I could see this working would be if there were some kind of right-hand assignment operator in ruby, which I&#8217;m fairly certain there isn&#8217;t.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rahim</title>
		<link>http://www.coffeepowered.net/2009/03/02/syntactic-sugar-will-occassionally-kick-your-puppies/comment-page-1/#comment-132</link>
		<dc:creator>Rahim</dc:creator>
		<pubDate>Tue, 03 Mar 2009 16:20:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.coffeepowered.net/?p=133#comment-132</guid>
		<description>In fact

irb(main):002:0&gt; bar = defined?(bar)
=&gt; &quot;local-variable&quot;

Shows the behaviour more clearly. (MRI 1.8.7)</description>
		<content:encoded><![CDATA[<p>In fact</p>
<p>irb(main):002:0&gt; bar = defined?(bar)<br />
=&gt; &#8220;local-variable&#8221;</p>
<p>Shows the behaviour more clearly. (MRI 1.8.7)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rahim</title>
		<link>http://www.coffeepowered.net/2009/03/02/syntactic-sugar-will-occassionally-kick-your-puppies/comment-page-1/#comment-131</link>
		<dc:creator>Rahim</dc:creator>
		<pubDate>Tue, 03 Mar 2009 16:17:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.coffeepowered.net/?p=133#comment-131</guid>
		<description>Interesting stuff, I&#039;ve come across the same problem a few times and never been satisfied, we want a false (and/or nil) preserving equivalent of &#124;&#124;=

Surely there&#039;s a cleaner or more idiomatic way of approaching this than using line separators?

Trashing around in IRB testing the behaviour I tried:

irb(main):002:0&gt; foo = defined?(foo) &#124;&#124; true
=&gt; &quot;local-variable&quot;

which was another result I wasn&#039;t expecting...</description>
		<content:encoded><![CDATA[<p>Interesting stuff, I&#8217;ve come across the same problem a few times and never been satisfied, we want a false (and/or nil) preserving equivalent of ||=</p>
<p>Surely there&#8217;s a cleaner or more idiomatic way of approaching this than using line separators?</p>
<p>Trashing around in IRB testing the behaviour I tried:</p>
<p>irb(main):002:0&gt; foo = defined?(foo) || true<br />
=&gt; &#8220;local-variable&#8221;</p>
<p>which was another result I wasn&#8217;t expecting&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Heald</title>
		<link>http://www.coffeepowered.net/2009/03/02/syntactic-sugar-will-occassionally-kick-your-puppies/comment-page-1/#comment-128</link>
		<dc:creator>Chris Heald</dc:creator>
		<pubDate>Mon, 02 Mar 2009 21:30:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.coffeepowered.net/?p=133#comment-128</guid>
		<description>@Scott - yeah, I usually do. The problem here was that &quot;false&quot; is a valid initialization value for the variable I was interested in, and I didn&#039;t want to clobber that if it was already set.</description>
		<content:encoded><![CDATA[<p>@Scott &#8211; yeah, I usually do. The problem here was that &#8220;false&#8221; is a valid initialization value for the variable I was interested in, and I didn&#8217;t want to clobber that if it was already set.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://www.coffeepowered.net/2009/03/02/syntactic-sugar-will-occassionally-kick-your-puppies/comment-page-1/#comment-127</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Mon, 02 Mar 2009 21:26:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.coffeepowered.net/?p=133#comment-127</guid>
		<description>You can just use:
&lt;code&gt;foobar &#124;&#124;= true&lt;/code&gt;
which will set foobar to true if it&#039;s undefined, nil, or false, but otherwise leave it&#039;s value the same.
It&#039;s just the same as:
&lt;code&gt;foobar = foobar &#124;&#124; true&lt;/code&gt;

Still, it&#039;s good to remember these tricky order of operations things.</description>
		<content:encoded><![CDATA[<p>You can just use:<br />
<code>foobar ||= true</code><br />
which will set foobar to true if it&#8217;s undefined, nil, or false, but otherwise leave it&#8217;s value the same.<br />
It&#8217;s just the same as:<br />
<code>foobar = foobar || true</code></p>
<p>Still, it&#8217;s good to remember these tricky order of operations things.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Heald</title>
		<link>http://www.coffeepowered.net/2009/03/02/syntactic-sugar-will-occassionally-kick-your-puppies/comment-page-1/#comment-126</link>
		<dc:creator>Chris Heald</dc:creator>
		<pubDate>Mon, 02 Mar 2009 21:26:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.coffeepowered.net/?p=133#comment-126</guid>
		<description>Well, it&#039;s a combination of the two, really. The real gotcha is that Ruby initializes variables as they&#039;re parsed, not as the code is run - I wasn&#039;t expecting that at all.</description>
		<content:encoded><![CDATA[<p>Well, it&#8217;s a combination of the two, really. The real gotcha is that Ruby initializes variables as they&#8217;re parsed, not as the code is run &#8211; I wasn&#8217;t expecting that at all.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: honzasterba</title>
		<link>http://www.coffeepowered.net/2009/03/02/syntactic-sugar-will-occassionally-kick-your-puppies/comment-page-1/#comment-125</link>
		<dc:creator>honzasterba</dc:creator>
		<pubDate>Mon, 02 Mar 2009 21:23:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.coffeepowered.net/?p=133#comment-125</guid>
		<description>This not as much about the trailing condition but about the defined? method which itself is pretty tricky and should be avoided. I myself spent a sleepless night trying to check if something is defined and write the code in a way that would not accidentally define it before the actual defined? is evaluated.</description>
		<content:encoded><![CDATA[<p>This not as much about the trailing condition but about the defined? method which itself is pretty tricky and should be avoided. I myself spent a sleepless night trying to check if something is defined and write the code in a way that would not accidentally define it before the actual defined? is evaluated.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
