danprince / restack

🥞 Prototype for a concatenative programming language
https://restack.surge.sh
6 stars 0 forks source link

Native interop #16

Open danprince opened 8 years ago

danprince commented 8 years ago

Figure out a mechanism for native interop. Examples and ideas:

Dedicated Namespace

import (document alert) from "js"

"div" document "createElement" .
"class" "test" "setAttribute" .

Kinda grim but can be easily wrapped up in abstractions.

import (div) from "html"

(class "test") div

ClojureScript Style

"class" "test" js/document "createElement" .

Requires botching the syntax to make namescaped symbols. Not a fan.

Keywords + Hiccup Style

import (to-html) from "html"

(:div (:class "test")) to-html

Nice declarativeness but gets lispy pretty quickly. Keywords might be a good thing for the language overall. Would require much better support for working with functions before evaluation.

Could quite easily be transformed with macros into a better intermediate structure.