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

Ki as a library? #28

Open
girvo opened this issue Oct 23, 2015 · 3 comments
Open

Ki as a library? #28

girvo opened this issue Oct 23, 2015 · 3 comments

Comments

@girvo
Copy link

girvo commented Oct 23, 2015

One of the things I'd love to work out how to do is load ki as a library in Node, specifically to write a Webpack loader for easier development workflows. Any ideas where to start with that, as lib/ki_run.js seems to have a lot of code involved

@lantiga
Copy link
Owner

lantiga commented Oct 23, 2015

Sounds great, a webpack workflow would be a very nice addition to ki.
You should look into how the live editor on ki-lang.org does it.
Specifically, take a look at main.js and ki.js.

@girvo
Copy link
Author

girvo commented Oct 26, 2015

I've nearly got it working, but got distracted porting wisp over to webpack (see here). I'll have another crack today!

Also, out of curiosity, how does ki go with importing macros? It's a pretty big missing feature in wisp; would be awesome if it was in ki, but I'm well aware how difficult it is to add considering it needs to work with the JS runtime at the end of the day!

@lantiga
Copy link
Owner

lantiga commented Oct 26, 2015

ki macros are a thin layer on top of sweet.js macros - they are not real lisp-style macros. Take a look at the ki macro entry in the API as well as the react example.

ki is essentially sweet.js macros all the way down, so it was easier to define macros this way, although they are way less powerful than lisp macros.

The way it works (both in ki_run and in ki.js which you can use as a lib) is that the compiler detects if a file contains the ki macro statement and will just embed them as a rule in the _sexpr macro (in ki.sjs), replacing /*__macros__*/. It's really naive, we could do a lot better, especially since sweet.js has recently introduced (a primitive form of) modules.

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

2 participants