-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add support for using *1, *2, *3, and *e #229
Comments
No, it's not really possible. A single "eval top block" can issue one to three commands to the REPL, so the value of these vars are not bound to last evaluation. Also, there's no I'll probably add an entry on the FAQ regarding these vars :) |
@mauricioszabo I see, that makes sense. 🙂 So am I right in assuming Chlorine does one-off evaluations to the Socket REPL instead of having an ongoing connection to it and that's why it's really not technically possible to achieve that? For instance, doing $ echo '(+ 1 1) (println "The value is" *1)' | nc 0 5555
user=> 2
The value is 2
nil but I'm not familiar with how Chlorine actually send the blocks when you evaluate them, so perhaps, this isn't feasible. |
No, it does have an ongoing connection. The problem is that when you evaluate anything, Chlorine tries to detect:
If Now, if You can check this yourself by trying to eval something, then evaluating |
BTW, a simple correction: Chlorine will try to detect the |
I see. That makes sense. So, it "works" but not in the way you would expect, making it less useful? I tried out the example and it worked just like you said it would. However, the example below didn't set I assume EDIT: Nvm, I just realised that evaluating the actual vars will obviously change the value of them again 🤦 My bad! This makes sense. Using the vars will be highly indeterministic, which make them less useful. |
Do you have a As for the The current code that does handle evals in Chlorine starts here: https://github.com/mauricioszabo/repl-tooling/blob/master/src/repl_tooling/repl_client/clojure.cljs#L95-L96 and goes to here: https://github.com/mauricioszabo/repl-tooling/blob/master/src/repl_tooling/repl_client/clojure.cljs#L40-L48 |
Thanks for taking the time to explain this so throughly. It's really appreciated. 🙂 |
Sorry for bringing this up again but when I woke up this morning I realised I didn't fully understand what you meant yesterday. Given that you said
So
So how come |
It is - but the problem is that when you evaluate something in Chlorine, it'll send other commands before your eval. So it'll be re-bind to the result of previous command - for example, the "set filename and/or row" |
@mauricioszabo perhaps I misunderstand how the REPL bind the dynamic variables, but anything before my eval shouldn't be a problem since |
Ok, so the thing is: if you don't have a ; Evaling (+ 1 2)
(set-row 19) ; Binds *1 to nil
(do
(+ 1 2)); Binds *2 to nil, and *1 to 3 Now, on the second evaluation, if you eval (set-row 19) ; Binds *1 to nil, *2 to 3, and *3 to nil
(do
*1) ; *1 is nil, so it'll bind *1 to nil, *2 to nil, and *3 to 3
|
@mauricioszabo thanks a lot, I finally get it! 🎉 Really appreciate you taking the time to explain this in detail. 🙂 |
When you evaluate a block, it would be nice to be able to use
*1
,*2
and*3
and*e
respectively to reference return values and the last exception.Taken from the Clojure docs:
It seems to be supported by most REPLs.
I'd be happy to contribute a small amount to make this happen if you're interested in pursuing it. 🙂
The text was updated successfully, but these errors were encountered: