-
Notifications
You must be signed in to change notification settings - Fork 136
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
Make --> bind IT for use anywhere in FORMS, and add -as->. #221
Conversation
Also to mention: I think I have the |
I'm not sure why, but the Travis CI build has finished successfully, but hasn't reported back here. |
I marked this for a review. I played a bit around and couldn't find a counter example where it would break but I'm still kind of afraid that some of the anaphora macros will expand in a stupid way and things will get ugly. Going over each one is out of the question I guess, that would be just too much work. Or maybe we can just try it and see... I hope nobody's powering spacecraft with Emacs :P |
That's fair. I might go through and add some more examples using more complicated anaphoric macros. Also I tried to find a space game or something in Emacs to make a joke about, but couldn't find one. I'm pretty disappointed, to be honest. |
Here are some examples mixing
|
Yes please, add them as tests and then we merge. Only the first three examples are picked for the documentation so if we don't want to show these add three "good ones" and place these after that. |
I added the tests. I added them as a separate commit, but I can squash them if you prefer. |
No problem! Thanks for your contribution! |
This code fixes #218, in a way that I think is fairly straightforward, and not error-prone. I've added a example to show the problem that was fixed.
It keeps the feature that if a FORM is a symbol, the code will treat that symbol as a function, and pass it the single arg
it
. I keep this only because it's a legacy feature; it's not how Clojure operates, and was surprising to me. But, as mentioned, I kept it.This also fixes a multiple-evaluation bug; if
it
appears multiple times in a FORM, the value will be evaluated multiple times. The following code prompts for input twice with the old-->
, but only once with this version.(--> (progn (read-from-minibuffer "How many prompts? ") 3) (+ it it))
As a helper method, this adds a new method
-as->
, which is a version of-->
that takes the variable explicitly, as opposed to-->
only usingit
. I think the standard dash.el nomenclature would be to name the anaphoric version with an extra dash, but the anaphoric version is-->
, and the version with one fewer dash (->
) is already used. Please let me know if there's a better name for this new function. The existing name is a riff on Clojure's, but beginning with a dash to fit in with names here.I'm happy to make changes, whether to the name, or anything else here.