Skip to content

Implement compile.cell #3

Open
Open
@asg017

Description

@asg017

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:

  1. Defining new variables - module.define
  2. Re-defining variables - module.redefine
  3. import variables - module.import
  4. Maybe deriving, e.g. import {...} with {...} ? But this probably goes with import above - module.derive
  5. 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions