Open danieltanfh95 opened 9 years ago
Ouch. I would be very careful with intra-process communication and side-effects.
Is it a necessary implementation step? Imho this kind of tackiness together with macro's of all things, would be a last, last, last resort means to work with (wisp) source.
Why not just do:
(ns foo
(:require fs [wisp.compiler :refer [compile]]))
(print (:code (compile (.to-string (fs/read-file-sync "src/index.wisp" :utf8))
{:no-map true})))
Note that I've just used the sync
version from fs
. I hate callbacks and event loops, and rarely need to resort to them. Even in Node.js... Although the programming style is useful to know and understand (why/when/how), its a dreadful mess, impossible to reason about and largely complects the entire exception chain in my opinion. Although wisp pays no special attention to the programming style (as it should), this doesn't mean one can't craft perfectly fine asynchronous expressions in wisp. Personally, still, I prefer to use bluebird
for promises in those cases. Much better control, less deep nesting of expressions, much easier to track what goes wrong.
That having said, there is some general consensus, at least in the Clojure community, that macro's should really be a last resort if there is no way to tackle a problem with regular (higher order) functions.
However looking at your skills, I'd say you should/would know that and this is a required computation step in your procedure... in which case, nothing said ^^
I wrote the following code to try compile all the wisp files in a folder. However, there seems to be nothing coming out of stdout of, "wisp -c {file}". The program just freezes there waiting for an output that never came.