<?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: Emulate C# Using Statement in Ruby</title>
	<atom:link href="http://andrewpeters.net/2007/09/27/emulate-c-using-statement-in-ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://andrewpeters.net/2007/09/27/emulate-c-using-statement-in-ruby/</link>
	<description>C# &#38; .NET Development, NHaml, PowerShell Gadget, Inflector.NET...</description>
	<pubDate>Fri, 12 Mar 2010 07:20:25 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Andrew</title>
		<link>http://andrewpeters.net/2007/09/27/emulate-c-using-statement-in-ruby/comment-page-1/#comment-259</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Thu, 20 Dec 2007 20:51:27 +0000</pubDate>
		<guid isPermaLink="false">http://andrewpeters.net/2007/09/27/emulate-c-using-statement-in-ruby/#comment-259</guid>
		<description>He Cedric,

Boo is cool. Extending the compiler is very cool but I'm worried about the mainstream applicability of the technique :-)

Andrew.</description>
		<content:encoded><![CDATA[<p>He Cedric,</p>
<p>Boo is cool. Extending the compiler is very cool but I&#8217;m worried about the mainstream applicability of the technique :-)</p>
<p>Andrew.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cedric Vivier</title>
		<link>http://andrewpeters.net/2007/09/27/emulate-c-using-statement-in-ruby/comment-page-1/#comment-256</link>
		<dc:creator>Cedric Vivier</dc:creator>
		<pubDate>Thu, 20 Dec 2007 20:24:22 +0000</pubDate>
		<guid isPermaLink="false">http://andrewpeters.net/2007/09/27/emulate-c-using-statement-in-ruby/#comment-256</guid>
		<description>Hey Andrew!

Sure Ruby is nice, however we can also have this in .NET when using the Boo language :)

using disposableObject = ObjectImplementingIDisposable():
     ...do something

boo having an extensible compiler, it is implemented as an AST macro like this ( [&#124; ... &#124;] constructs are used for meta-programming in Boo) :

macro using:

	

	expansion = using.Block

	for expression as Expression in reversed(using.Arguments):

		temp = ReferenceExpression("__using${_context.AllocIndex()}__")

		assignment = [&#124; $temp = $expression as System.IDisposable &#124;].withLexicalInfoFrom(expression)

		

		expansion = [&#124;

			$assignment

			try:

				$expansion

			ensure:

				if $temp is not null:

					$temp.Dispose()

					$temp = null

		&#124;]

		

	return expansion</description>
		<content:encoded><![CDATA[<p>Hey Andrew!</p>
<p>Sure Ruby is nice, however we can also have this in .NET when using the Boo language :)</p>
<p>using disposableObject = ObjectImplementingIDisposable():<br />
     &#8230;do something</p>
<p>boo having an extensible compiler, it is implemented as an AST macro like this ( [| ... |] constructs are used for meta-programming in Boo) :</p>
<p>macro using:</p>
<p>	expansion = using.Block</p>
<p>	for expression as Expression in reversed(using.Arguments):</p>
<p>		temp = ReferenceExpression(&#8221;__using${_context.AllocIndex()}__&#8221;)</p>
<p>		assignment = [| $temp = $expression as System.IDisposable |].withLexicalInfoFrom(expression)</p>
<p>		expansion = [|</p>
<p>			$assignment</p>
<p>			try:</p>
<p>				$expansion</p>
<p>			ensure:</p>
<p>				if $temp is not null:</p>
<p>					$temp.Dispose()</p>
<p>					$temp = null</p>
<p>		|]</p>
<p>	return expansion</p>
]]></content:encoded>
	</item>
</channel>
</rss>
