Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheme list <--> JS array conversion and proxying #24

Open
jathak opened this issue Mar 24, 2018 · 0 comments
Open

Scheme list <--> JS array conversion and proxying #24

jathak opened this issue Mar 24, 2018 · 0 comments

Comments

@jathak
Copy link
Owner

jathak commented Mar 24, 2018

The old interpreter did this automatically whenever these objects passed between the two languages, which was a bad decision that lead to some hacks like:

; array lives in js land to avoid expensive conversion
(define sequence ((js "(arr)=>(type, a, b) => {\n"
  "if (type === 'add') {\n"
  "   arr.unshift(a); return;\n"
  "}\n"
  "if (type === 'dump') {a(true, arr); return;}\n"
  "return arr.slice("
    "Math.max(0, arr.length - a - b), "
    "Math.max(0, arr.length - a));\n"
"}\n") nil))

from lib/music.scm

Because of this, I made Scheme pairs and JS arrays pass to the other language with no conversion. JS arrays are readable in Scheme through code like (js-ref (js "[1, 2, 3]") "1"), but there's currently no good way to manipulate Scheme pairs from JS (due to dart2js making the properties unreadable).

There are two things I'd like to do:

  • Add list->js-array and js-array->list procedures, or possibly piggy-back off vectors (Add vectors #23)
  • Pass proxies to JS instead of the pairs themselves, to allow JS to access first and second directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant