Sublime Forum

Clojure evaluation

#1

Hi.

I like to write code on Clojure.
But after emacs it’s hard without slime and expression evaluation.

So, I wrote a little socket-based REPL and Sublime plugin for it.

First, download and build github.com/kondratovich/socket-repl.
Second, download github.com/kondratovich/evaluate. Instructions in README.

Now, you can run socket-repl and evaluate selected clojure expressions. Results will be in console.

Any suggestions ? You are welcome.

0 Likes

#2

Practical Clojure and Joy of Clojure. The former is more of an intro while the latter is an intermediate book.

0 Likes

#3

If you wish, you can try using SublimeREPL with Clojure.

code.wuub.net/sublimerepl/

viewtopic.php?f=5&t=2964

It seems to be working rather well, when compared to the PITA that Ruby’s IRB is.

0 Likes

#4

Hey, it works! neat plugin, thank you Andrew. And both the .clj and .py scripts are so cleanly written - I like how they just apply functions to data - as opposed to other approaches.

I see two ways in which this program could be improved. First, I don’t find all comfortable having to select the expressions prior to evaluating them. I’d just keep reading the input until the first parens/bracket/… is matched.

And second - I’d show the output in the console that is running the REPL server’s rather than in Sublime’s, as a) it’s more general-purpose -as the same program could serve other editors- and b) I don’t like to see Sublime’s and REPL’s output all mixed.

I reckon that actually it’d be fun and motivating to implement them myself but - perhaps you’d had no problem in adding those features?

Cheers - Victor.

0 Likes

#5

[quote=“vemv”]First, I don’t find all comfortable having to select the expressions prior to evaluating them. I’d just keep reading the input until the first parens/bracket/… is matched.
[/quote]

Agreed! This would be a great addition.

0 Likes

#6

Agreed! This would be a great addition.[/quote]

Actually, I think what Clooj does is even simpler; it looks in both directions for a blank line, and evaluates everything between blank lines. So if you have a block of (def ) expressions, for example, you can evaluate them all with one stroke. But if you’re working in a function, it usually has blank lines before and after, so you grab and evaluate just the function.

0 Likes

#7

I just pushed a change to SublimeREPL adding better block transfer for Clojure. Just set your cursor after the last bracket of the function you want evaluated and press F2, b

Multiple cursors are supporter. Use Shift+F2, B to experiment.

0 Likes