On this page:
6.1 Namespaces
make-js-namespace
reset-js-namespace!
6.2 Values
6.3 Objects
object
attributed
bit-flag-set?
READ-ONLY?
DONT-ENUM?
DONT-DELETE?
ref?
set-ref!
delete-ref!
deref
array
function?
has-property?
has-property/ immediate
has-attribute?
object-get
object-set!
object-delete!
object-keys-stream
6.4 Java Script Library
global-object
install-standard-library!
Version: 4.1.0.2

6 Runtime System

This library implements the JavaScript runtime system. It be can required via:

 (require (planet dherman/javascript:6/runtime))

6.1 Namespaces

(make-js-namespace)  namespace?

Creates a PLT namespace containing the standard JavaScript top-level bindings.

(reset-js-namespace! ns)  any

  ns : namespace?

Resets the global object in JavaScript namespace ns.

6.2 Values

A JavaScript value is represented as one of:

6.3 Objects

JavaScript objects are represented with the following structure type:

(struct

 

object

 

(call construct proto class properties))

  call : function?

  construct : function?

  proto : object?

  class : string?

  properties : (hash-of string? property?)

A JavaScript object.

A property is one of:

Plain value properties are assumed to have no attributes. An attributed value may have any combination of the attributes DONT-ENUM?, READ-ONLY?, and DONT-DELETE?.

(struct

 

attributed

 

(value attributes))

  value : value?

  attributes : bit-set?

A bit-set is an efficient representation of a set of booleans.

(bit-flag-set? x bit)  boolean?

  x : bit-field?

  bit : bit?

Checks for a bit in a bit set.

READ-ONLY? : bit?

A bit representing the ECMAScript ReadOnly attribute.

DONT-ENUM? : bit?

A bit representing the ECMAScript DontEnum attribute.

DONT-DELETE? : bit?

A bit representing the ECMAScript DontDelete attribute.

A property-value is one of:

A ref is a special property with custom get, set, and delete behavior.

(ref? x)  boolean?

  x : any

Determines whether x is a ref.

(set-ref! x v)  any

  x : ref?

  v : value?

Invoke x’s setter.

(delete-ref! x)  any

  x : ref?

Invoke x’s deleter.

(deref x)  any

  x : ref?

Invoke x’s getter.

JavaScript array values are represented specially for faster access of numeric properties:

(struct

 

(array object)

 

(vector))

  vector : (evector-of property?)

(function? x)  boolean?

  x : any

Determines whether a value is a callable object.

(has-property? x key)  boolean?

  x : object?

  key : string?

Checks for the presence of property key in x, searching the prototype chain if necessary.

(has-property/immediate x key)  boolean?

  x : object?

  key : string?

Checks for the presence of property key in x without searching the prototype chain.

(has-attribute? x bit)  boolean?

  x : property?

  bit : bit?

Checks for attribute bit in property x.

(object-get x key)  (optional/c value?)

  x : object?

  key : string?

Attempts to lookup property key in x.

(object-set! x key v)  any

  x : object?

  key : string?

  v : value?

Sets property key in x.

(object-delete! x key)  any

  x : object?

  key : string?

Attempts to delete property key from x.

(object-keys-stream x)  (-> string?)

  x : object?

Produces an enumeration stream consistent with JavaScript’s for..in semantics.

6.4 JavaScript Library

global-object : object?

The global object.

(install-standard-library! global)  any

  global : object?

Installs the properties of the standard library in global.