<?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: Python says hello to Ruby</title>
	<atom:link href="http://blog.tomasm.net/2009/04/15/python-says-hello-to-ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tomasm.net/2009/04/15/python-says-hello-to-ruby/</link>
	<description>IronRuby, DLR, .NET Framework</description>
	<lastBuildDate>Sun, 07 Feb 2010 17:16:15 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: tomasmatousek</title>
		<link>http://blog.tomasm.net/2009/04/15/python-says-hello-to-ruby/#comment-14</link>
		<dc:creator>tomasmatousek</dc:creator>
		<pubDate>Sat, 16 May 2009 06:35:59 +0000</pubDate>
		<guid isPermaLink="false">http://matousek.wordpress.com/2009/04/15/python-says-hello-to-ruby/#comment-14</guid>
		<description>The easiest way is as follows:
&lt;pre&gt;
rb&gt; #py
py&gt; class c(object):
py&#124;   def foo(self, a, b):
py&#124;     print self, &quot;a:&quot;, a, &quot;b:&quot;, b
py&#124;
py&gt; #rb
rb&gt; c.new.foo(1,2)
&lt;c object at 0x000000000000002B&gt; a: 1 b: 2
=&gt; nil
rb&gt;
&lt;/pre&gt;
In the example above, IronPython defines the class &quot;c&quot; (lower case c) on the current module. The variables of the module are exposed as variables of the corresponding DLR scope. The REPL shares the scope accross multiple executions. IronRuby accesses variables on it via method calls. In Ruby, &quot;c.new.foo&quot; are actually 3 methods calls - of methods &quot;c&quot;, &quot;new&quot; and &quot;foo&quot; in this order. There is no method &quot;c&quot; defined on top-level main singleton (nor on Object or Kernel module). Therefore &quot;method_missing&quot; defined by IronRuby on top-level main singleton is invoked. Its implementation looks into the DLR scope for variable &quot;c&quot; and finds the Python class. 

Now if the Python class name starts with a capital letter we need to do &quot;C().new.foo&quot; or &quot;self.C.new.foo&quot; because &quot;C.new.foo&quot; in Ruby is a constant lookup &quot;C&quot; followed by methods calls to &quot;new&quot; and &quot;foo&quot;. Since we do &quot;unmangle&quot; names for .NET method calls (you can use both &quot;create_engine&quot; and &quot;CreateEngine&quot; to call C# method &quot;CreateEngine&quot;) we might as well do this for scope lookups in a future version of IronRuby. Then you could define &quot;class MyClass(object)&quot; and access it from Ruby as &quot;my_class&quot;.</description>
		<content:encoded><![CDATA[<p>The easiest way is as follows:</p>
<pre>
rb&gt; #py
py&gt; class c(object):
py|   def foo(self, a, b):
py|     print self, "a:", a, "b:", b
py|
py&gt; #rb
rb&gt; c.new.foo(1,2)
&lt;c object at 0x000000000000002B&gt; a: 1 b: 2
=&gt; nil
rb&gt;
</pre>
<p>In the example above, IronPython defines the class &#8220;c&#8221; (lower case c) on the current module. The variables of the module are exposed as variables of the corresponding DLR scope. The REPL shares the scope accross multiple executions. IronRuby accesses variables on it via method calls. In Ruby, &#8220;c.new.foo&#8221; are actually 3 methods calls &#8211; of methods &#8220;c&#8221;, &#8220;new&#8221; and &#8220;foo&#8221; in this order. There is no method &#8220;c&#8221; defined on top-level main singleton (nor on Object or Kernel module). Therefore &#8220;method_missing&#8221; defined by IronRuby on top-level main singleton is invoked. Its implementation looks into the DLR scope for variable &#8220;c&#8221; and finds the Python class. </p>
<p>Now if the Python class name starts with a capital letter we need to do &#8220;C().new.foo&#8221; or &#8220;self.C.new.foo&#8221; because &#8220;C.new.foo&#8221; in Ruby is a constant lookup &#8220;C&#8221; followed by methods calls to &#8220;new&#8221; and &#8220;foo&#8221;. Since we do &#8220;unmangle&#8221; names for .NET method calls (you can use both &#8220;create_engine&#8221; and &#8220;CreateEngine&#8221; to call C# method &#8220;CreateEngine&#8221;) we might as well do this for scope lookups in a future version of IronRuby. Then you could define &#8220;class MyClass(object)&#8221; and access it from Ruby as &#8220;my_class&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Blank</title>
		<link>http://blog.tomasm.net/2009/04/15/python-says-hello-to-ruby/#comment-13</link>
		<dc:creator>Doug Blank</dc:creator>
		<pubDate>Fri, 15 May 2009 18:13:59 +0000</pubDate>
		<guid isPermaLink="false">http://matousek.wordpress.com/2009/04/15/python-says-hello-to-ruby/#comment-13</guid>
		<description>Thanks for this sample! Can you provide a sample in Ruby of the other direction? For example, can you define a class in Python and use in Ruby? I can&#039;t figure out what you have to require/include to access a class, if it is possible.</description>
		<content:encoded><![CDATA[<p>Thanks for this sample! Can you provide a sample in Ruby of the other direction? For example, can you define a class in Python and use in Ruby? I can&#8217;t figure out what you have to require/include to access a class, if it is possible.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
