Changes between Version 11 and Version 12 of JavaScriptingAPI
- Timestamp:
- 05/12/09 20:31:10 (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
JavaScriptingAPI
v11 v12 13 13 The main interface defined by JSR-223, {{{javax.script.ScriptEngine}}}, is implemented by the class [http://trac.common-lisp.net/armedbear/browser/trunk/abcl/src/org/armedbear/lisp/scripting/AbclScriptEngine.java org.armedbear.lisp.scripting.AbclScriptEngine]. !AbclScriptEngine is intended to be a singleton, and as such it has a protected constructor. You can obtain an instance of !AbclScriptEngine using the [http://trac.common-lisp.net/armedbear/browser/trunk/abcl/src/org/armedbear/lisp/scripting/AbclScriptEngineFactory.java AbclScriptEngineFactory] or by using the service provider mechanism through !ScriptEngineManager (refer to the javax.script documentation). 14 14 15 === Configuration file ===15 === Startup and configuration file === 16 16 17 17 At startup (i.e. when its constructor is invoked, as part of the static initialization phase of !AbclScriptEngineFactory) the ABCL script engine attempts to load an "init file" from the classpath (/abcl-script-config.lisp). If present, this file can be used to customize the behaviour of the engine, by setting a number of variables in the ABCL-SCRIPT package. Here is a list of the available variables: … … 27 27 * Default value: 4005 28 28 29 Additionally, at startup the !AbclScriptEngine will (require 'asdf) - in fact, it uses asdf to load Swank. 30 29 31 === Evaluation === 30 32 31 Code is read and evaluated in the package ABCL-SCRIPT-USER. This packages USEs the COMMON-LISP, JAVA and ABCL-SCRIPT packages. Future versions of the script engine might make this default package configurable. The load function is used under the hood for evaluating code, and thus the same behavior of load is guaranteed. This allows, among other things, in-package forms change the package in which the loaded code is read.33 Code is read and evaluated in the package ABCL-SCRIPT-USER. This packages USEs the COMMON-LISP, JAVA and ABCL-SCRIPT packages. Future versions of the script engine might make this default package configurable. The load function is used under the hood for evaluating code, and thus the same behavior of load is guaranteed. This allows, among other things, in-package forms to change the package in which the loaded code is read. 32 34 33 35 It is possible to evaluate code in what JSR-223 calls a "!ScriptContext" (basically a flat environment of name->value pairs). This context is used to establish special bindings for all the variables defined in it; since variable names are strings from Java's point of view, they are first interned using READ-FROM-STRING with, as usual, ABCL-SCRIPT-USER as the default package. Variables are declared special because CL's load, eval and compile functions work in a null lexical environment and would ignore non-special bindings. 34 36 35 Contrary to what the function load does, evaluation of multiple forms returns the value of the last form.37 Contrary to what the function load does, evaluation of a series of forms returns the value of the last form instead of T. 36 38 37 39 === Compilation ===