<?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:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
	>
<channel>
	<title>Comments on: Getting Pedantic About Ruby Semantics</title>
	<atom:link href="http://avdi.org/devblog/2010/03/01/getting-pedantic-about-ruby-semantics/feed/" rel="self" type="application/rss+xml" />
	<link>http://avdi.org/devblog/2010/03/01/getting-pedantic-about-ruby-semantics/</link>
	<description>"...the three great virtues of a programmer: laziness, impatience, and hubris." -- Larry Wall</description>
	<lastBuildDate>Thu, 09 Sep 2010 09:18:34 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Sebastian Günther</title>
		<link>http://avdi.org/devblog/2010/03/01/getting-pedantic-about-ruby-semantics/comment-page-1/#comment-993</link>
		<dc:creator>Sebastian Günther</dc:creator>
		<pubDate>Thu, 04 Mar 2010 05:56:22 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=489#comment-993</guid>
		<description>Avdi, you have sparked my interest with your comments on Yehuda posts. I&#039;m questioning whether their is one true source to explain Rubys semantic at all. I could use a pragmatic approach and use Rubyspec and Rubinus to describe the semantic with the same (language) abstraction level. Or I could put much effort into understanding MRI or JRuby and explain what happens there. &lt;br&gt;&lt;br&gt;And this is curious: The mental model preforms my understanding of the languages internal workings. And as I want to understand how the metaprogramming capabilities of Ruby work, choosing the right model is essential.&lt;br&gt;&lt;br&gt;But what is the &quot;right model&quot;?</description>
		<content:encoded><![CDATA[<p>Avdi, you have sparked my interest with your comments on Yehuda posts. I&#39;m questioning whether their is one true source to explain Rubys semantic at all. I could use a pragmatic approach and use Rubyspec and Rubinus to describe the semantic with the same (language) abstraction level. Or I could put much effort into understanding MRI or JRuby and explain what happens there. </p>
<p>And this is curious: The mental model preforms my understanding of the languages internal workings. And as I want to understand how the metaprogramming capabilities of Ruby work, choosing the right model is essential.</p>
<p>But what is the &#8220;right model&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sebastian Günther</title>
		<link>http://avdi.org/devblog/2010/03/01/getting-pedantic-about-ruby-semantics/comment-page-1/#comment-859</link>
		<dc:creator>Sebastian Günther</dc:creator>
		<pubDate>Wed, 03 Mar 2010 21:56:22 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=489#comment-859</guid>
		<description>Avdi, you have sparked my interest with your comments on Yehuda posts. I&#039;m questioning whether their is one true source to explain Rubys semantic at all. I could use a pragmatic approach and use Rubyspec and Rubinus to describe the semantic with the same (language) abstraction level. Or I could put much effort into understanding MRI or JRuby and explain what happens there. &lt;br&gt;&lt;br&gt;And this is curious: The mental model preforms my understanding of the languages internal workings. And as I want to understand how the metaprogramming capabilities of Ruby work, choosing the right model is essential.&lt;br&gt;&lt;br&gt;But what is the &quot;right model&quot;?</description>
		<content:encoded><![CDATA[<p>Avdi, you have sparked my interest with your comments on Yehuda posts. I&#39;m questioning whether their is one true source to explain Rubys semantic at all. I could use a pragmatic approach and use Rubyspec and Rubinus to describe the semantic with the same (language) abstraction level. Or I could put much effort into understanding MRI or JRuby and explain what happens there. </p>
<p>And this is curious: The mental model preforms my understanding of the languages internal workings. And as I want to understand how the metaprogramming capabilities of Ruby work, choosing the right model is essential.</p>
<p>But what is the &#8220;right model&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wycats</title>
		<link>http://avdi.org/devblog/2010/03/01/getting-pedantic-about-ruby-semantics/comment-page-1/#comment-853</link>
		<dc:creator>wycats</dc:creator>
		<pubDate>Mon, 01 Mar 2010 16:41:25 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=489#comment-853</guid>
		<description>&quot;memoizing the Proc is an allowable optimization&quot; disregards the fact that it&#039;s actually *true* in all implementations.&lt;br&gt;&lt;br&gt;There&#039;s an open bug in 1.8.x in which changing the metaclass of the Proc produces a different Proc across method boundaries, but this is (a) fixed in 1.9, and (b) not a bug in Rubinius and JRuby.&lt;br&gt;&lt;br&gt;I say it&#039;s a bug because if you read the actual C code, you can see the mistake (a use of CLASS_OF without rb_class_real).&lt;br&gt;In implementations without this bug, you can modify the metaclass of a Proc and it will persist across method boundaries. Additionally, this is *actually* the implementation in Rubinius.&lt;br&gt;&lt;br&gt;Also, this model doesn&#039;t neatly handle the case of &amp; where the object itself is not a Proc. In all implementations, &amp;foo calls to_proc on foo, and the returned Proc is passed to the method. In order to understand this behavior using the &quot;reified block&quot; model, you need to also posit that the block is extracted from the returned Proc and then reattached later. This step is entirely unneeded to explain what is happening.&lt;br&gt;&lt;br&gt;Since it *is not* always happening in practice (for instance, in Rubinius), and the step is unneeded to explain the observed phenomenon, why should we add it to our model of the phenomenon?</description>
		<content:encoded><![CDATA[<p>&#8220;memoizing the Proc is an allowable optimization&#8221; disregards the fact that it&#39;s actually *true* in all implementations.</p>
<p>There&#39;s an open bug in 1.8.x in which changing the metaclass of the Proc produces a different Proc across method boundaries, but this is (a) fixed in 1.9, and (b) not a bug in Rubinius and JRuby.</p>
<p>I say it&#39;s a bug because if you read the actual C code, you can see the mistake (a use of CLASS_OF without rb_class_real).<br />In implementations without this bug, you can modify the metaclass of a Proc and it will persist across method boundaries. Additionally, this is *actually* the implementation in Rubinius.</p>
<p>Also, this model doesn&#39;t neatly handle the case of &#038; where the object itself is not a Proc. In all implementations, &#038;foo calls to_proc on foo, and the returned Proc is passed to the method. In order to understand this behavior using the &#8220;reified block&#8221; model, you need to also posit that the block is extracted from the returned Proc and then reattached later. This step is entirely unneeded to explain what is happening.</p>
<p>Since it *is not* always happening in practice (for instance, in Rubinius), and the step is unneeded to explain the observed phenomenon, why should we add it to our model of the phenomenon?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2010/03/01/getting-pedantic-about-ruby-semantics/comment-page-1/#comment-852</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Mon, 01 Mar 2010 16:18:08 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=489#comment-852</guid>
		<description>As far as I can tell, your model is more a platonic ideal than anything anyone else has put forward - in that it tries to explain observed phenomenon in terms of processes which don&#039;t actually take place in MRI. This isn&#039;t a bad thing - most mature language standards *must* set forth a kind of platonic ideal if they are to remain implementation neutral. They describe the semantics, not the mechanics.&lt;br&gt;&lt;br&gt;It just seems to me that you are trying to describe your platonic ideal as THE shared mental model that Ruby coders should keep in mind - and that&#039;s going to bite people unless and until you are able to convince Ruby implementors that your described semantics are the ones they should strive to preserve. If that&#039;s what you&#039;re trying to do here - put forward a semantic model you think *should* be the common mental baseline for Ruby implementors - then just say so. But I don&#039;t think it&#039;s accurate yet to say that this model is the one that all implementors are already keeping in mind as they build their runtimes.</description>
		<content:encoded><![CDATA[<p>As far as I can tell, your model is more a platonic ideal than anything anyone else has put forward &#8211; in that it tries to explain observed phenomenon in terms of processes which don&#39;t actually take place in MRI. This isn&#39;t a bad thing &#8211; most mature language standards *must* set forth a kind of platonic ideal if they are to remain implementation neutral. They describe the semantics, not the mechanics.</p>
<p>It just seems to me that you are trying to describe your platonic ideal as THE shared mental model that Ruby coders should keep in mind &#8211; and that&#39;s going to bite people unless and until you are able to convince Ruby implementors that your described semantics are the ones they should strive to preserve. If that&#39;s what you&#39;re trying to do here &#8211; put forward a semantic model you think *should* be the common mental baseline for Ruby implementors &#8211; then just say so. But I don&#39;t think it&#39;s accurate yet to say that this model is the one that all implementors are already keeping in mind as they build their runtimes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2010/03/01/getting-pedantic-about-ruby-semantics/comment-page-1/#comment-851</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Mon, 01 Mar 2010 16:06:24 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=489#comment-851</guid>
		<description>The thing is, we can also posit a third model where, as in the spec, a block is a non-object part of a method&#039;s execution context. It is only reified as a Proc when a &amp;block argument is specified, and memoizing that Proc object is an allowable optimization. This model is no less elegant and fits the observed phenomena equally well. At least one commenter on your article put forth this model or one very similar to it, and you dismissed them as if yours was clearly the more valid mental model.&lt;br&gt;&lt;br&gt;I don&#039;t think yours is a *bad* model, but I don&#039;t see what makes it more valid than any other. The fact that one implementation of Ruby chose this model doesn&#039;t convince me, especially since I suspect MRI did not go this route (I haven&#039;t had time to check the source to confirm that).</description>
		<content:encoded><![CDATA[<p>The thing is, we can also posit a third model where, as in the spec, a block is a non-object part of a method&#39;s execution context. It is only reified as a Proc when a &#038;block argument is specified, and memoizing that Proc object is an allowable optimization. This model is no less elegant and fits the observed phenomena equally well. At least one commenter on your article put forth this model or one very similar to it, and you dismissed them as if yours was clearly the more valid mental model.</p>
<p>I don&#39;t think yours is a *bad* model, but I don&#39;t see what makes it more valid than any other. The fact that one implementation of Ruby chose this model doesn&#39;t convince me, especially since I suspect MRI did not go this route (I haven&#39;t had time to check the source to confirm that).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wycats</title>
		<link>http://avdi.org/devblog/2010/03/01/getting-pedantic-about-ruby-semantics/comment-page-1/#comment-850</link>
		<dc:creator>wycats</dc:creator>
		<pubDate>Mon, 01 Mar 2010 15:56:29 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=489#comment-850</guid>
		<description>@avdi &quot;And when standards no more reflect reality than any given hacker’s imagination, the question becomes: what semantics do you think the language should have, moving forward?&quot;&lt;br&gt;&lt;br&gt;Here&#039;s the thing. My imagination reflects reality, while the standard does not. So while it&#039;s true that &quot;the standards reflect reality no more than my imagination&quot;, they certainly reflect reality less than my imagination.&lt;br&gt;&lt;br&gt;I think a very good touchstone for reality is how Rubinius thinks of the world, since much of it is implemented in Ruby. Consider the following code:&lt;br&gt;&lt;br&gt;def bar(&amp;block) block end&lt;br&gt;foo = proc { 1 }&lt;br&gt;bar(&amp;foo)&lt;br&gt;&lt;br&gt;In Rubinius, foo is passed directly to bar, because, in Rubinius, &amp;foo means &quot;get the Proc from foo and and send the result to the method&quot;.&lt;br&gt;&lt;br&gt;This view of the world clearly explains why sending a block across multiple methods retains object identity, while the Proc.new approach in the spec, in addition to being provably false (as you demonstrated) does not explain it.&lt;br&gt;&lt;br&gt;When choosing between two competing descriptions of the same phenomenon, we tend to choose the description that most fits with the phenomenon being described, not a &quot;platonic ideal&quot; of what we wish we were seeing.</description>
		<content:encoded><![CDATA[<p>@avdi &#8220;And when standards no more reflect reality than any given hacker’s imagination, the question becomes: what semantics do you think the language should have, moving forward?&#8221;</p>
<p>Here&#39;s the thing. My imagination reflects reality, while the standard does not. So while it&#39;s true that &#8220;the standards reflect reality no more than my imagination&#8221;, they certainly reflect reality less than my imagination.</p>
<p>I think a very good touchstone for reality is how Rubinius thinks of the world, since much of it is implemented in Ruby. Consider the following code:</p>
<p>def bar(&#038;block) block end<br />foo = proc { 1 }<br />bar(&#038;foo)</p>
<p>In Rubinius, foo is passed directly to bar, because, in Rubinius, &#038;foo means &#8220;get the Proc from foo and and send the result to the method&#8221;.</p>
<p>This view of the world clearly explains why sending a block across multiple methods retains object identity, while the Proc.new approach in the spec, in addition to being provably false (as you demonstrated) does not explain it.</p>
<p>When choosing between two competing descriptions of the same phenomenon, we tend to choose the description that most fits with the phenomenon being described, not a &#8220;platonic ideal&#8221; of what we wish we were seeing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Etienne Vallette d&#39;Osia</title>
		<link>http://avdi.org/devblog/2010/03/01/getting-pedantic-about-ruby-semantics/comment-page-1/#comment-849</link>
		<dc:creator>Etienne Vallette d&#39;Osia</dc:creator>
		<pubDate>Mon, 01 Mar 2010 13:35:51 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=489#comment-849</guid>
		<description>I have never said this correction fixes this problem :-)&lt;br&gt;&lt;br&gt;I tested it on ruby 1.9.1, jruby and rubinius, none of them print the line &quot;in Proc.new&quot;, so I am certain it is a spec issue&lt;br&gt;&lt;br&gt;rvm ruby test.rb :&lt;br&gt;&lt;br&gt;jruby-1.4.0: jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java HotSpot(TM) Client VM 1.6.0_15) [i386-java] &lt;br&gt;&lt;br&gt;in foo&lt;br&gt;in bar&lt;br&gt;in block&lt;br&gt;&lt;br&gt;rbx-1.0.0-rc2: rubinius 1.0.0-rc2 (1.8.7 release 2010-01-04 JI) [i686-pc-linux-gnu] &lt;br&gt;&lt;br&gt;in foo&lt;br&gt;in bar&lt;br&gt;in block&lt;br&gt;&lt;br&gt;ree-1.8.7-2010.01: ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-linux], MBARI 0x8770, Ruby Enterprise Edition 2010.01 &lt;br&gt;&lt;br&gt;in foo&lt;br&gt;in bar&lt;br&gt;in block&lt;br&gt;&lt;br&gt;ruby-1.8.7-p249: ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux] &lt;br&gt;&lt;br&gt;in foo&lt;br&gt;in bar&lt;br&gt;in block&lt;br&gt;&lt;br&gt;ruby-1.9.1-p378: ruby 1.9.1p378 (2010-01-10 revision 26273) [i686-linux] &lt;br&gt;&lt;br&gt;in foo&lt;br&gt;in bar&lt;br&gt;in block</description>
		<content:encoded><![CDATA[<p>I have never said this correction fixes this problem <img src='http://avdi.org/devblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I tested it on ruby 1.9.1, jruby and rubinius, none of them print the line &#8220;in Proc.new&#8221;, so I am certain it is a spec issue</p>
<p>rvm ruby test.rb :</p>
<p>jruby-1.4.0: jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java HotSpot(TM) Client VM 1.6.0_15) [i386-java] </p>
<p>in foo<br />in bar<br />in block</p>
<p>rbx-1.0.0-rc2: rubinius 1.0.0-rc2 (1.8.7 release 2010-01-04 JI) [i686-pc-linux-gnu] </p>
<p>in foo<br />in bar<br />in block</p>
<p>ree-1.8.7-2010.01: ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-linux], MBARI 0&#215;8770, Ruby Enterprise Edition 2010.01 </p>
<p>in foo<br />in bar<br />in block</p>
<p>ruby-1.8.7-p249: ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux] </p>
<p>in foo<br />in bar<br />in block</p>
<p>ruby-1.9.1-p378: ruby 1.9.1p378 (2010-01-10 revision 26273) [i686-linux] </p>
<p>in foo<br />in bar<br />in block</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2010/03/01/getting-pedantic-about-ruby-semantics/comment-page-1/#comment-848</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Mon, 01 Mar 2010 11:13:15 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=489#comment-848</guid>
		<description>I went ahead and updated the code sample, thanks for the note!</description>
		<content:encoded><![CDATA[<p>I went ahead and updated the code sample, thanks for the note!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2010/03/01/getting-pedantic-about-ruby-semantics/comment-page-1/#comment-847</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Mon, 01 Mar 2010 11:09:52 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=489#comment-847</guid>
		<description>You&#039;re right about super, but it doesn&#039;t matter in this example because the method is never called anyway (at least, not in MRI 1.8.7).</description>
		<content:encoded><![CDATA[<p>You&#39;re right about super, but it doesn&#39;t matter in this example because the method is never called anyway (at least, not in MRI 1.8.7).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Etienne Vallette d&#39;Osia</title>
		<link>http://avdi.org/devblog/2010/03/01/getting-pedantic-about-ruby-semantics/comment-page-1/#comment-846</link>
		<dc:creator>Etienne Vallette d&#39;Osia</dc:creator>
		<pubDate>Mon, 01 Mar 2010 10:42:35 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=489#comment-846</guid>
		<description>Your redefinition is wrong, you actually replace the existing new method, instead of adding one (class methods are singleton methods of the class object), so super can&#039;t work.&lt;br&gt;class &lt;&lt; Proc&lt;br&gt;  alias old_new new&lt;br&gt;  def new(&amp;block)&lt;br&gt;    puts &quot;in Proc.new&quot;&lt;br&gt;    old_new(&amp;bloc)&lt;br&gt;  end&lt;br&gt;end&lt;br&gt;&lt;br&gt;I think Yehuda is right and the specs should be changed, but what *I* think is not important ;-)&lt;br&gt;You should send a small mail to mailing-list.</description>
		<content:encoded><![CDATA[<p>Your redefinition is wrong, you actually replace the existing new method, instead of adding one (class methods are singleton methods of the class object), so super can&#39;t work.<br />class &lt;&lt; Proc<br />  alias old_new new<br />  def new(&#038;block)<br />    puts &#8220;in Proc.new&#8221;<br />    old_new(&#038;bloc)<br />  end<br />end</p>
<p>I think Yehuda is right and the specs should be changed, but what *I* think is not important <img src='http://avdi.org/devblog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> <br />You should send a small mail to mailing-list.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
