Runtime.Globals actually don't contain Ruby global variables ($xxx). IronRuby 
publishes global modules defined by a script to this scope.

IronRuby 0.9.1.0 on .NET 2.0.50727.4918
Copyright (c) Microsoft Corporation. All rights reserved.

>>> class C
... end
=> nil
>>> module D
... end
=> nil
>>> IronRuby.globals.methods(false)
=> ['c', 'd']
>>> IronRuby.globals.C
=> C
>>> IronRuby.globals.D
=> D

IronRuby.globals is a singleton method that returns the DLR Scope object 
corresponding to Runtime.Globals.
True Ruby global variables ($ prefixed variables) are listed by 
global_variables Ruby method:

>>> global_variables
=> ["~", "&", "+", "`", "'", "_", "0", "!", "@", "*", "/", ",", ";", "\\", "<", 
">", "\"", ":", ".", "?", "PROGRAM_NAME"
, "stdin", "stdout", "defout", "stderr", "LOADED_FEATURES", "LOAD_PATH", "-I", 
"-O", "-F", "FILENAME", "VERBOSE", "-v",
"-w", "DEBUG", "-d", "KCODE", "-K", "SAFE", "$"]

Tomas

From: ironruby-core-boun...@rubyforge.org 
[mailto:ironruby-core-boun...@rubyforge.org] On Behalf Of cdur...@tsys.com
Sent: Wednesday, September 30, 2009 8:59 AM
To: ironruby-core@rubyforge.org
Cc: ironruby-core@rubyforge.org; ironruby-core-boun...@rubyforge.org
Subject: Re: [Ironruby-core] Clear ScriptEngine Global Variables


Is that thread-safe? I'd be worried about deleting entries from a collection 
I'm iterating through without knowing the implementation.

--
Chuck Durfee
Lead Software Architect, CentreSuite
TSYS iSolutions, Golden
Email cdur...@tsys.com<mailto:cdur...@tsys.com>


Ivan Porto Carrero <i...@flanders.co.nz<mailto:i...@flanders.co.nz>>
Sent by: 
ironruby-core-boun...@rubyforge.org<mailto:ironruby-core-boun...@rubyforge.org>

09/30/2009 07:56 AM
Please respond to
ironruby-core@rubyforge.org<mailto:ironruby-core@rubyforge.org>


To

ironruby-core@rubyforge.org<mailto:ironruby-core@rubyforge.org>

cc

Subject

Re: [Ironruby-core] Clear ScriptEngine Global Variables










if (Runtime.Globals.ContainsVariable(className)) 
Runtime.Globals.RemoveVariable(className);




---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz<http://flanders.co.nz/>
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)



On Wed, Sep 30, 2009 at 3:43 PM, Aaron Clauson 
<li...@ruby-forum.com<mailto:li...@ruby-forum.com>> wrote:
Hi,

Is there anyway to clear all global variables from the IronRuby script
engine?

For example if I define a variable in a script and execute it:

$myVar = "Hello"

And then execute another script in a new scriptscope but with the same
ScriptEngine instance and use:

 global_variables.each do |var|
   print("#{var} = #{eval('$' + var)}")
 end

Then the myVar variable from the first instance will be listed.

Thanks,

Aaron
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org<mailto:Ironruby-core@rubyforge.org>
http://rubyforge.org/mailman/listinfo/ironruby-core
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org<mailto:Ironruby-core@rubyforge.org>
http://rubyforge.org/mailman/listinfo/ironruby-core
________________________________

The information contained in this communication (including any attachments 
hereto) is confidential and is intended solely for the personal and 
confidential use of the individual or entity to whom it is addressed. If the 
reader of this message is not the intended recipient or an agent responsible 
for delivering it to the intended recipient, you are hereby notified that you 
have received this communication in error and that any review, dissemination, 
copying, or unauthorized use of this information, or the taking of any action 
in reliance on the contents of this information is strictly prohibited. If you 
have received this communication in error, please notify us immediately by 
e-mail, and delete the original message. Thank you
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to