2
votes

EDIT: is what I want basically load-string?

Question

In Clojure, if I do:

(require :reload 'foo.bar)

then Clojure looks for src/foo/bar.clj, and reloads it.

Now, I want to do something like this:

(reload-from-string 'foo.bar STR)

the semantics of this would be: reload namespace 'foo.bar, but instead of compiling src/foo/bar.clj, compile STR instead.

How do I define reload-from-string?

Context

I need to hot reload code on a server that is running an Clojure application. I don't want to have to continuously shuffle files back & forth to the server (either via scp, sftp, or fuse/sshfs) in order to reload. Thus, I would prefer to just pass it a string.

Thanks!

1

1 Answers

1
votes

You can use read-string and then eval. Keep in mind the risks though. An advantage of splitting them up is you can whitelist what is present in the resulting list before evaling it.

You probably want to bind *read-eval* to false also.