Open
Description
compile.module
takes in a "program" as string, parses with parseModule
, and outputs a define
function to create a runtime module.
compile.cell
should take in a "cell" as a string, parse with parseCell
, but I'm not sure what it should output.
The output should work for:
- Defining new variables -
module.define
- Re-defining variables -
module.redefine
import
variables -module.import
- Maybe deriving, e.g.
import {...} with {...}
? But this probably goes withimport
above -module.derive
- Maybe deleting variables? But this doesnt really make sense (since you write code to delete a variable - maybe -
variable.delete
A very rough guess could be:
const define = compile.module(`
a = 1
b = 2
c = 3
`)
const module = runtime.module(define)
await module.value("a") // 1
await module.value("b") // 2
await module.value("c") // 3
let {define, redefine} = compile.cell(`a = b`)
redefine(module)
await module.value("a") // should now be 2
let {define} = compile.cell(`d = c`)
define(module)
await module.value("d") // should be 4 (including redefine example from above)
But idk how import cells could work like this :/
compile.cell
could also take in a module as a parameter - for example:
const define = compile.module(`a = 1
b = 2
c= a + b`)
const module = runtime.module(define)
compile.cell(`a = 4`, module)
But I don't like this too much, since 1) how do you distinguish from define/redefine/imports, and 2) I want it to have a similar signature as compile.module
(take in a string, return a function you can use to define).