<?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, 24 Aug 2010 01:23:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<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 07: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>&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!</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 16: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&#039;m fairly certain there isn&#039;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 10: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)</p>
<p>=&gt; &quot;local-variable&quot;</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 10: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&#039;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&#039;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</p>
<p>=&gt; &quot;local-variable&quot;</p>
<p>which was another result I wasn&#039;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 15: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 &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.</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 15: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:</p>
<p>&lt;code&gt;foobar ||= true&lt;/code&gt;</p>
<p>which will set foobar to true if it&#039;s undefined, nil, or false, but otherwise leave it&#039;s value the same.</p>
<p>It&#039;s just the same as:</p>
<p>&lt;code&gt;foobar = foobar || true&lt;/code&gt;</p>
<p>Still, it&#039;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 15: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&#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 &#8211; I wasn&#039;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 15: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>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached
Page Caching using memcached
Database Caching 9/22 queries in 0.012 seconds using memcached

Served from: www.coffeepowered.net @ 2010-09-09 10:44:39 -->