<?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: Evaluating code dynamically in Groovy (differences with Ruby)</title>
	<atom:link href="http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/feed/" rel="self" type="application/rss+xml" />
	<link>http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/</link>
	<description>Personal Page</description>
	<lastBuildDate>Thu, 12 Apr 2012 09:59:54 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Nicholas Sterling</title>
		<link>http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/comment-page-1/#comment-543</link>
		<dc:creator>Nicholas Sterling</dc:creator>
		<pubDate>Wed, 09 Mar 2011 05:38:52 +0000</pubDate>
		<guid isPermaLink="false">http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/#comment-543</guid>
		<description>&lt;p&gt;Jorge, this is exactly what I needed.  Thanks for taking the time to write this up!&lt;/p&gt;

&lt;p&gt;I&#039;m curious about what Angsuman had to say; too bad he didn&#039;t give more details.&lt;/p&gt;

&lt;p&gt;Have you noticed that things work inside the interactive groovysh?  The following line fails just as you describe as a hey.groovy script executed with &quot;groovy hey.groovy&quot; but works perfectly when typed into groovysh.&lt;/p&gt;

&lt;p&gt;def hey() { println &quot;Hey!&quot; }; evaluate(&quot;hey()&quot;)&lt;/p&gt;

&lt;p&gt;Perhaps groovysh is using something akin to the closure technique you describe?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Jorge, this is exactly what I needed.  Thanks for taking the time to write this up!</p>

<p>I&#8217;m curious about what Angsuman had to say; too bad he didn&#8217;t give more details.</p>

<p>Have you noticed that things work inside the interactive groovysh?  The following line fails just as you describe as a hey.groovy script executed with &#8220;groovy hey.groovy&#8221; but works perfectly when typed into groovysh.</p>

<p>def hey() { println &#8220;Hey!&#8221; }; evaluate(&#8220;hey()&#8221;)</p>

<p>Perhaps groovysh is using something akin to the closure technique you describe?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: vitalii</title>
		<link>http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/comment-page-1/#comment-460</link>
		<dc:creator>vitalii</dc:creator>
		<pubDate>Thu, 02 Dec 2010 14:51:46 +0000</pubDate>
		<guid isPermaLink="false">http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/#comment-460</guid>
		<description>&lt;p&gt;THANK YOU !!!!!! Thank you Jorge !!! Thank you Internet!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>THANK YOU !!!!!! Thank you Jorge !!! Thank you Internet!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Angsuman Chakraborty, Editor Gaea Times</title>
		<link>http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/comment-page-1/#comment-457</link>
		<dc:creator>Angsuman Chakraborty, Editor Gaea Times</dc:creator>
		<pubDate>Mon, 25 Oct 2010 09:54:57 +0000</pubDate>
		<guid isPermaLink="false">http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/#comment-457</guid>
		<description>&lt;p&gt;In Groovy you can directly call evaluate() within the script to evaluate a file in current context.
Any variables and closures in the file are available to the calling script.&lt;/p&gt;

&lt;p&gt;However there is a simpler way.
You can static import (like java) to make all the static methods available within the calling script.&lt;/p&gt;

&lt;p&gt;Note: You can also do a regular import.&lt;/p&gt;

&lt;p&gt;You know an even simpler way to call static methods in a script within the same directory?
abc.methodName() where abc is the name of script and methodName is the static method defined within the script. I will have to say that these are even simpler options than Ruby.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>In Groovy you can directly call evaluate() within the script to evaluate a file in current context.
Any variables and closures in the file are available to the calling script.</p>

<p>However there is a simpler way.
You can static import (like java) to make all the static methods available within the calling script.</p>

<p>Note: You can also do a regular import.</p>

<p>You know an even simpler way to call static methods in a script within the same directory?
abc.methodName() where abc is the name of script and methodName is the static method defined within the script. I will have to say that these are even simpler options than Ruby.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Jorge Manrubia</title>
		<link>http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/comment-page-1/#comment-425</link>
		<dc:creator>Jorge Manrubia</dc:creator>
		<pubDate>Thu, 20 May 2010 10:43:05 +0000</pubDate>
		<guid isPermaLink="false">http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/#comment-425</guid>
		<description>&lt;p&gt;Thank you for the tip Josef&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thank you for the tip Josef</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Josef</title>
		<link>http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/comment-page-1/#comment-424</link>
		<dc:creator>Josef</dc:creator>
		<pubDate>Thu, 20 May 2010 02:39:01 +0000</pubDate>
		<guid isPermaLink="false">http://jorgemanrubia.net/2009/10/10/evaluating-code-dynamically-in-groovy/#comment-424</guid>
		<description>&lt;p&gt;Jorge:
The following script, without using the external code file, shows the &#039;problem&#039; more succinctly:&lt;/p&gt;

&lt;p&gt;&lt;code lang=&quot;groovy&quot;&gt;
//file: SayExperiment.groovy
def say(message){
    println message
}

def shell = new GroovyShell()
def code = &quot;say hello&quot;
shell.evaluate(code)
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Anyway, I used your technique in a recent post &quot;Groovy Object Notation (GrON) for Data Interchange&quot; at http://wp.me/psHIY-6g&lt;/p&gt;

&lt;p&gt;--- Josef&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Jorge:
The following script, without using the external code file, shows the &#8216;problem&#8217; more succinctly:</p>

<p>

<div class="codecolorer-container groovy blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="groovy codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">//file: SayExperiment.groovy</span><br />
<a href="http://www.google.de/search?q=site%3Agroovy.codehaus.org/%20def"><span style="color: #000000; font-weight: bold;">def</span></a> say<span style="color: #66cc66;">&#40;</span>message<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <a href="http://www.google.de/search?q=site%3Agroovy.codehaus.org/%20println"><span style="color: #993399;">println</span></a> message<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<a href="http://www.google.de/search?q=site%3Agroovy.codehaus.org/%20def"><span style="color: #000000; font-weight: bold;">def</span></a> shell <span style="color: #66cc66;">=</span> <a href="http://www.google.de/search?q=site%3Agroovy.codehaus.org/%20new"><span style="color: #000000; font-weight: bold;">new</span></a> GroovyShell<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />
<a href="http://www.google.de/search?q=site%3Agroovy.codehaus.org/%20def"><span style="color: #000000; font-weight: bold;">def</span></a> code <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;say hello&quot;</span><br />
shell.<span style="color: #006600;">evaluate</span><span style="color: #66cc66;">&#40;</span>code<span style="color: #66cc66;">&#41;</span></div></div>

</p>

<p>Anyway, I used your technique in a recent post &#8220;Groovy Object Notation (GrON) for Data Interchange&#8221; at <a href="http://wp.me/psHIY-6g" rel="nofollow">http://wp.me/psHIY-6g</a></p>

<p>&#8212; Josef</p>]]></content:encoded>
	</item>
</channel>
</rss>

