How do you create Scheme objects on the Javascript side of Hoot?

I want to create Scheme objects in Javascript and store them in Javascript variables so that I may be able to read them on Hoot with a (ref eq) returning define-foreign. How do you go about doing that?

I don’t know what would convertToScmValueHootCanRead be, or if it even exists.

let scm_globals = new Map();

// You can pack it up with some values:
scm_globals.set("cow", convertToScmValueHootCanRead("🐮"));

// in the Hoot FFI handlers:

{
  // ...
  globals: {
    readScmGlobals: (key) => scm_globals.get(key),
    setScmGlobals: (key, value) => scm_globals.set(key, value),
  },
  // ...
}

and then

(define-foreign globals-ref
  "interface" "readScmGlobals"
  (ref string)
  -> (ref eq))

(define-foreign set-globals!
  "interface" "setScmGlobals"
  (ref string)
  (ref eq)
  -> none)

I looked into the manual, but things like the MutableString class, for example, do not work the way I thought it would works.

Thank you!

You can’t create Scheme objects from JS without exporting functions from your Wasm binary to do so. The JS side is a reflection library, and classes like MutableString are for inspecting values from Scheme, not creating new ones. Generally speaking, you want to drive your application from Scheme, not JS.