-
Notifications
You must be signed in to change notification settings - Fork 68
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
Macros Can't find any functions on the REPL or try-wisp #124
Comments
Yes this has being one of the most painful blockers in getting a macro imports working and in general making macros really useful. Right now The issue is that I'm afraid I don't have much time to dedicate to this, but I'm more then happy to help to any volunteer ;) |
To be clear that problem is quite tricky and it requires proper implementation of compile and runtime phases. Meaning that during complete time I suspect simple hacky implementation could be made by changing |
Ok, I don't know enough about macro systems to work on this, but I'm curious how the chain macro example works then, since it calls reduce/cons/first/rest and those all have to be imported. |
@vshesh Well, through the use of reader macro's for the most of it I guess. Syntax-quote just does that. But also since there is a precompilation process which makes it a lot easier. I added the chain operator (or thread-first macro as its called in Clojure) to var expandThreadFirst = exports.expandThreadFirst = function expandThreadFirst() {
var operations = Array.prototype.slice.call(arguments, 0);
return reduce(function (form, operation) {
return cons(first(operation), cons(form, rest(operation)));
}, first(operations), rest(operations));
};
installMacro('->', expandThreadFirst); And they would work for a few reasons, one being JS is lenient with non-existing objects and functions and given the correct context, suddenly (when executed there) the variables may be around in scope or, even more importantly I guess, because they are referenced explicitly in the expander.wisp source. I've had more than enough cases where I needed to reference the namespace by fully qualified name (e.g. wisp.string/replace) in order for it to work. |
A lot of macros will fail to be accepted on the repl command line.
I give this ns first (so you know everything has been imported)
And then I try something like:
Which looks like there's something else going on here with the way regular functions and macros interact - it seems like they're not finding each other?
I can replicate this with a much simpler example:
It's even replicable with the base functions
The text was updated successfully, but these errors were encountered: