Skip to content

Instantly share code, notes, and snippets.

View kriskowal's full-sized avatar

Kris Kowal kriskowal

View GitHub Profile

SharedStructs are to be declarations, like class declarations, that may appear in module source text. Instances of a shared struct are JavaScript primitives and, like all other JavaScript primitives, share a per-Realm prototype instance. So, like 1..toString() looks up the %NumberPrototype% intrinsic for the realm in the current execution context in order to call its toString method, when we have a struct instance s, calling s.toString() will look up the struct’s corresponding prototype on the realm in the current execution context. The key space for that table closes over the key space of the realm’s module map and also includes the position of the struct declaration. Consequently, shared struct declarations must instantiate all contained prototypes once per evaluation of a module in the realm’s module map.

I am comfortable with this strategy in anticipation of a suitable intersection semantics for Module Harmony proposa

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import { makeStream, nullQueue } from '@endo/stream';
/**
* @template TValue
*/
const makePubSub = () => {
// Request pubsub async queue internals
let { promise: tailPromise, resolve: tailResolve } = makePromiseKit();
import { makeStream, nullQueue } from '@endo/stream';
/**
* @template TValue
*/
const makePubSub = () => {
// Request pubsub async queue internals
let { promise: tailPromise, resolve: tailResolve } = makePromiseKit();
const makeNearReader = reader =>
Far('Reader', {
async next() {
const iteration = await reader.next();
if (iteration.done) {
return iteration;
}
return harden({ value: encodeBase64(iteration.value) });
},
async return(value) {
{
"colors": {
"darkBlue": "#61B2E4",
"darkRed": "#D22F27",
"darkGreen": "#5C9E31",
"lightPurple": "#B399C8"
},
"levels": [
{
"topology": "torus",
/**
* @template T
* @typedef {object} Schema
* @prop {() => T} number
* @prop {() => T} boolean
* @prop {() => T} string
* @prop {(t: T) => T} optional
* @prop {(t: T) => T} list
* @prop {(t: T) => T} dict
* @prop {(shape: Record<string, T>) => T} struct
{
"colors": {
"lightBlue": "#92D3F5",
"darkBlue": "#61B2E4",
"lightRed": "#EA5A47",
"darkRed": "#D22F27",
"lightGreen": "#B14CC3",
"darkGreen": "#5C9E31",
"lightYellow": "#FCEA2B",
"darkYellow": "#F1B31C",

Module Harmony Dependency Graph

graph LR;

subgraph Compartments Layer 0

  ModuleSourceConcept[module source concept];

  ModuleSourceInstance[ModuleSource instance];