It would take a bit of refactoring: Changing the `env` list to a table, adding it as a parameter of `ac-macro?` (which should now look things up from that table first), and finally adding an `env` parameter to Arc's `eval`.
What's the benefit of running vim-slime as opposed to just an arc repl from the command line? I've been doing that w/ the same vim/tmux setup you mentioned. I enjoy it.
Edit: I see that you can execute code from the vim window. That is a nice feature. Anything else significant?
No, that's pretty much it. I sometimes find it useful, but yes, mostly I forget it exists. Occasionally it'll bother me when I hit ctrl-c for unrelated reasons :)
I read the link you suggested in my previous post about defvar, and I see that it can be used to set dynamic behavior when a variable is referenced (??). Is this the correct interpretation, and what might be some uses of that?
Yeah it lets you decide what to do when getting or setting a variable. The original link has an example at the bottom, but here's another one kinda related to what you seem to be trying to do:
arc> (= h (obj a 1 b 2))
#hash((a . 1) (b . 2))
arc> (defvar a
(fn args
(if args
; write
(= h!a car.args)
; read
h!a)))
arc> a
1
arc> (= a 3)
3
arc> a
3
arc> h
#hash((a . 3) (b . 2))
Wow great post, thanks for the reply. I didn't know eval was always executed at global scope, and I was not thinking about the ht variable being executed multiple times at different scope, so thanks for pointing that out. The rest of your explanation about how to get it working is very clear and I will be a better arc hacker for it!
The occasion for this macro is an object system built around closures and hash tables. I will post more about it when I've made more progress.
I was using defvar where I should have been using =. But the idea in my post was just to store the result of (prompt) in the variable x, which is meant to be a string.
And yes, now that I am moving past the experimental phase of my script, I will be running things in batch mode.
I like it! I don't think it'll break anything; can you send a pull request? Then we'll be able to run such code reliably at the repl! That would be sweet.
Edit 38 minutes later: hmm, there's one issue. Right now you can type multiple expressions in on a single line, but this change would drop everything after the end of the first expression. A better approach would be to drop only whitespace and stop at the very first non-whitespace character.