Re: Interpreter scoping, possible bug

Patrick Niemeyer <[email protected]> Sun, 23 Jan 2005 14:36:02 -0600
Newsgroups gmane.comp.java.beanshell.devel
Message-ID <[email protected]>
On Jan 23, 2005, at 8:52 AM, Darren Govoni wrote:

>    I have a situation where I want to compartmentalize each script I 
> evaluate in an interpreter. Right now, I'm using a separate 
> interpreter for each script. Is there a significant cost to doing 
> this? The reason is that I set some variables on the interpreter that 
> are unique to each script and I don't want any co-mingling of these 
> variables or access.

The interpreter is pretty lightweight...  The main performance issue 
would be the overhead of parsing a script repeatedly vs. keeping the 
script parsed in the interpreter. (Check out:  
http://beanshell.org/manual/parser.html#Parsing_and_Performance)

But if you're scripts don't write global variables that conflict, etc. 
then they should be able to live in one interpreter... just put them 
into different method bodies or objects...

>    What is the basic overhead cost of an interpreter? e.g. threads.

BeanShell doesn't start any threads of its own.  It's pretty much what 
you see is what you get...

>  Also, I have noticed a peculiar thing. In a callback method from my 
> application to a 'class' instantiated in beanshell and exposed to the 
> Java app, some variables will not access properly WITHOUT a class 
> declaration. The script just halts when you try to access, without a 
> runtime exception. I'm using the latest beta jar of BSH and JDK1.5_01.


Hmm...  I'm not sure that I understand exactly.  On a regular bsh 
object you'd need to use the getVariable() method... Are you saying 
that that doesn't return?


Pat



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl