Evaluate verses GroovyShell.evaluate

View: New views
2 Messages — Rating Filter:   Alert me  

Evaluate verses GroovyShell.evaluate

by Darren Pulsipher :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am trying to do some fun things with evaluation of user typed expressions.

I saw both evaluate(String) and GroovyShell.evaluate(string).

Are these the same methods or are they different. If different how are they different?

--
Darren Pulsipher

Re: Evaluate verses GroovyShell.evaluate

by Jochen Theodorou :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Darren Pulsipher schrieb:
> I am trying to do some fun things with evaluation of user typed expressions.
>
> I saw both evaluate(String) and GroovyShell.evaluate(string).
>
> Are these the same methods or are they different. If different how are
> they different?

one major difference, that comes to my mind is that evaluate is
available per default in scripts, but not normal classes. Also evaluate
shares its binding with the evaluated and then executed script, while in
GroovyShell you have to explicitly create a shell that shares the
binding... that is if you wish for that.

They are not fundamentally different. Sorting all the "evals" in Groovy
beginning with the less flexible and ending with the most flexible I
would have this order: evaluate(String), GroovyShell, GroovyClassLoader,
  CompilationUnit.

bye blackdrag

--
Jochen "blackdrag" Theodorou
The Groovy Project Tech Lead (http://groovy.codehaus.org)
http://blackdragsview.blogspot.com/


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email