Subj : Re: Read-only variables .... To : Bruno Vignola From : Igor Bukanov Date : Mon Dec 15 2003 04:59 pm Bruno Vignola wrote: > Hi all! > > I am a new rhino user, so I am sorry if my questions > are trivial but I was not able to find anything in the > docs so far ... > > - It is possible to define "read-only" variables? You can not do it from JavaScript as Rhino does not support const keyword as SpiderMonkey (Mozilla JS engine) does. From Java you can add ScriptableObject.READONLY flag when calling Scriptable.Object.defineProperty() to create read-only properties. Note that a variable is just a property of a scope object. > > - Furthermore, it is possible to list the content of > a context? Is there any method for doing this job? You are confusing Context instances and scope objects. Context instances do not store any script data, it is scopes and other instances of Scriptable that do. See http://www.mozilla.org/rhino/scopes.html for details. To get enumeratable properties (i.e. ones that "for (i in object)" will enumerate) stored in Scripatble instance, use Scriptable.getIds(). To get all properties, check if Scripatble instance also implements org.mozilla.javascript.debug.DebuggableObject which contains getAllIds method to get all properties. Regards, Igor .