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

running compiled file #132

Open
StreetStrider opened this issue Aug 16, 2015 · 4 comments
Open

running compiled file #132

StreetStrider opened this issue Aug 16, 2015 · 4 comments

Comments

@StreetStrider
Copy link

Hi. I have some beginner question, but readme does not cover it. The docs say:

wisp does not depend on the JVM and is completely self-hosted

Does this mean that wisp does not require its own runtime? Here's the example:

echo '(eval (quote (+ 1 2 3)))' | wisp

which results in:

eval(list(symbol(void 0, '+'), 1, 2, 3));

This is a valid piece of JS code, but neither node neither browser knows anything about list and symbol, and eval too, since it's just a name collision. So, I expect there's some wisp core which contains definitions for this functions and I should bundle my code with it to run it in node or browser.

Readme has good explanation of syntax and even which JS code it will be compiled to. But it has no simple answer on how to run code and bundle. I think it should cover this issues in first place.

@robjens
Copy link

robjens commented Aug 26, 2015

Hi @StreetStrider,

Right, your assessment is correct that neither node nor browser know anything about any list function. This is defined in wisp.sequence so one typically needs to include that library in the following fashion:

(ns foo.bar
  (:require [wisp.sequence :refer [list]]))

However, adding only that form to the top of the file won't help much either. You also need to include the symbol symbol, since you are syntax quoting the form. The + operator is however, not required to be loaded explicitly here, = however is, == isn't. It takes a little knowledge of the wisp file organization to know where you can find what you need (or if it even exists in wisp). I tend to use this github Project Search bar on top to check if there is a function by the name in wisp, second I built my own augmentations library and copied/modified a whole bunch more of Clojure core functions. The main point is though, there are very few core library functions enabled out-of-the-box, as one would be used to when having used Clojure for a but. In wisp, most of it is explicit reference. Anyway it gives decent enough feedback in case there is a missing symbol (say you thought you could get empty? from wisp.runtime but it is actually in wisp.sequence. It just not tells you which namespace to find it at. Mostly: let, if, not, defn, fn and a few more I can't recall, that will work out-of-the-box.

(ns foo.bar
  (:require [wisp.sequence :refer [list]]
            [wisp.ast :refer [symbol]]))

(print (eval (quote (+ 1 2 3)))

Stick that in a file, say foo.wisp and run wisp foo.wisp, you'll see the JavaScript object that makes a list (head/tail cons'd structure).

P.S. This requires/assumes a npm i --save wisp locally to the project

P.P.S. Inspect the source a la wisp -c foo.wisp --no-map for clean-cut JavaScript without inline sourcemap.

@StreetStrider
Copy link
Author

@robjens, hi. Thanks for head's up. I like the explicit style. Well, I definitely should investigate wisp's namespace.

@chr15m
Copy link
Collaborator

chr15m commented Feb 7, 2017

@StreetStrider @robjens do you guys have a suggested change to the current docs that would clear this up for users?

@StreetStrider
Copy link
Author

Hello, @chr15m. I do not. You can send a PR, but this project is out of maintainers' scope for now. I saw a deprecation warning. As of issue, I think there must be a simple way (like a single option) to bundle generated code with all required runtime (maybe bloated, redundant, but working for absolutely sure).

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

3 participants