Skip to main content

Module foreign

Module foreign 

Source
Expand description

The bridge of foreign_call(runtime, module, member, arguments) (warp’s lowering/foreign/foreign_modules.rs, notes/stdlib_connectors.md), shared by warp and its executables (card exe-foreign): one long-lived child per runtime and process, started on first use, speaking one JSON line per request and per answer. Python: python3 -u running FOREIGN_PYTHON_LOOP (WARP_PYTHON names another interpreter); JavaScript: node running FOREIGN_JS_LOOP (WARP_NODE), a global (Math) or a module it requires. A read gives the member itself, a call gives its result (a promise awaited); an exception is an error with the runtime’s message. A value without a JSON form stays in its runtime behind an id, a handle: it crosses as the record {$handle: 7, type: "date", text: "datetime.date(2020, 1, 2)"} and is that object again when it comes back, as an argument or as the receiver of d.isoformat() (the module position). Handles live until the process ends. A warp function given as an argument crosses as {$warp_function: 0}, its index among the call’s functions; node calls it back with the line {callback: 0, arguments: […]} and waits for its {value} or {error} (card js-callbacks).

Constants§

BIG_INTEGER_KEY
An integer beyond 64 bits, sent as its digits: {"$int": "15511210043330985984000000"}
CODEPOINT_KEY
A codepoint (a WIT char, P94), which JSON would make a text: {"$char": "b"}
WARP_FUNCTION_KEY
A warp function among a call’s arguments: {"$warp_function": 0}

Functions§

call
runtime.module.member(arguments…) (arguments null: the member itself, read): the value the runtime answered, or its error as runtime module.member: error; module is a module’s name or a handle, module_name how errors name it
is_interpreted
Is runtime one an interpreter runs (python, js)

Type Aliases§

Callback
How a call’s warp functions are called back: by their index, with the arguments the runtime gave them as a list