This section describes the conventions used here to describe type signatures.
A [T]
is an array-like value (only ever used read-only in this API), i.e., one with an integer length
and whose indexed properties from 0 to length - 1
are of type T
.
A type T?
should be read as T | undefined
-- that is, an optional value that may be undefined
.
A realm object abstracts the notion of a distinct global environment.
Extensible web: This is the dynamic equivalent of a same-origin <iframe>
without DOM.
r = new Realm(options, // {
// eval: {
// direct: {
// translate: ((string) -> string)?,
// fallback: ((any, ...any) -> any)?
//. }?,
// indirect: ((string) -> any)?
// }?,
// Function: ((string, string, ("function" | "function*")) -> function)?
// }?
initializer); // ((object) -> any)?
Every component of the constructor argument is optional (meaning that it can be undefined
and will be provided with a default behavior).
The initializer object is passed an object containing the standard ECMAScript builtins for a global object. A host environment may also provide additional builtins specific to the host environment. (For example, the browser would provide atob
and btoa
and other standard browser globals that are not tied to the DOM.) The this
binding of the initializer function is provided as the new realm object. This can be used to initialize the realm, for example:
var realm = new Realm(options, function(builtins) {
Object.mixin(this.global, builtins);
});
The global object associated with the realm.
Synchronously execute a top-level script.
Extensible web: This is the dynamic equivalent of a <script>
in HTML.
// eval : (string) -> any
v = r.eval(src)
This section describes how the Loader
class is extended to integrate with custom realms.
l = new Loader({
realm, // Realm?
...
}) // : Loader<ModuleAddress, ModuleSource>
Returns the realm associated with the loader.
Convenience: returns the global associated with the loader's realm.
Is this proposal alive?