Core Modules

All compiled WebScheme programs are Wasm modules. They can either be executable (i.e. no exports, usually a start function), or they represent a library definition:

  • import and export declarations translate to Wasm imports and exports, respectively.
  • Any definitions from begin, include, or include-ci declarations translate to global variables or functions.
  • Any non-definition expressions from begin, include, or include-ci declarations are evaluated in-order in the start function.
  • include-library-declarations may similarly add to the start function, and it may also add to the imports / exports.

Type ABI

WARNING

WebScheme will depend on the final implementation of the GC proposal, so this design is subject to change.

Scheme type predicateWasm type
boolean?(type (mut i32))
bytevector?(type (array (mut i8)))
char?(type (mut i32))
eof-object?unary?*
null?unary?*
number?(variant (case "exact" i64) (case "inexact" f64))
pair?(type (struct (mut anyref) (mut anyref)))
port?TODO
procedure?(type funcref)
string?(type (mut string))
symbol?(type string)
vector?(type (array (mut anyref)))

* Would it be possible to represent unary types with Wasm's proposed "variant" types?

The union of all these types, as well as the common record supertype defined below, is referred to $t-obj and is generally the type of all globals and function parameters and return values (with some exceptions).

Record Types

Ideally, types defined using define-record-type would be implemented using extensible union types as mentioned in the post-MVP section of the GC proposal.