I’m happy to announce that sideloading support in unravel is complete.
Start a plain old repl:
Clojure 1.8.0
user=> (require ’[net.cgrand.xforms :as x])
FileNotFoundException Could not locate net/cgrand/xforms__init.class or net/cgrand/xforms.clj on classpath. clojure.lang.RT.load (RT.java:456)Now connect unravel to it with additional entries on the classpath:
$ scripts/run -cp .:$HOME/.m2/repository/net/cgrand/xforms/0.9.5/xforms-0.9.5.jar:$HOME/.m2/repository/net/cgrand/macrovich/0.2.0/macrovich-0.2.0.jar 5555
Unravel 0.2.2 connected to localhost:5555
Type ^O for full docs of symbol under cursor, ^D to quit
Enter #__help for help
user=> (require '[net.cgrand.xforms :as x])
nil
user=> (x/into {} (x/by-key odd? x/count) (range 10))
{false 5, true 5}
EDIT:
It’s worth noting that xforms requires macrovich. So recursive requires are supported “for free” (without any support at the sideloader level)oh, wow, it works with jars too. That's basically what would be needed by CIDER. That's amazing. I'm sure @benedek and @bozhidar would be excited by this.
Btw nothing prevents a client from extending a classpath dynamically
yeah, for sure.
I mean, in theory you could say "I will handle any require of replant.XXXXXX" and load it with x, y and z functions.
The 34 lines of the sideloader are there https://github.com/Unrepl/unravel/blob/sideloader/src/unravel/loop.cljs#L290-L324
yes on missed require you could ask the user if they want to perform a repo lookup and add the dep etc.
I’ve been rambling with the sideloader idea for so long (and having struggled to communicate it), that I’m happy to see it works
> I (@dominicm) just didn’t understand the gap between jar and base64 encoded class. you are asked for a resource, you open the zip (jar), check if the resource is in it, if found you extract it, base64 it and send it
I might attempt something like this for juxt/edge's training mode. It's quite nice to not have to worry people with require's whilst we're getting them to grips with the foundations of the language.
@pesterhazy @volrath @dominicm Does anyone remember what I proposed for autocomple: prefix, suffix returns a list of maps? I think there was a third argument
namespace! that was the 3rd one, right?
if it wasn't, it probably should be
although, doesn't unrepl know the current ns?
if you complete for a file that you are editing out of the repl buffer, no
Logbot is on vacation since Oct 20th so...
ah, I see.
slack is increasingly not the best place for this I suppose.
this being the whole clojurians thingy?
Slack, yes. Not to repeat discussions elsewhere, with much heat, but Slack's business model doesn't align with community's much. I'm not advocating for a move, I think the sheer # of people far surpasses many of the costs.
@cgrand, yes, namespace I think
thanks for the confirmation
Ah! I forgot package.json
If I haven't aot'd my clojure code, I suppose I can't do a base64 of the class. Is that reconcilable?
Base64 of the ns should be enough. Except if you try something fancy.
@dominicm despite the name classloaders load more than classes
Awesome. I thought it was very jvm centric, cool to hear that it isn't.