Can a clojure application expose an API to clojure plugins?


#1

Some programs expose plugin APIs to python or perl plugins. Can I do the same with clojure?

Update: It seems https://bitbucket.org/zilti/clojure-jsr-223 can potentially do what I want.


#2

You can call into Clojure from any JVM-based language using the built-in API documented here https://clojure.org/reference/java_interop#_calling_clojure_from_java


#3

I was looking for a way to embed a clojure script in a clojure program in the same way you expose certain C API to lua scripts run by embedded lua runtime.


#4

I’m not sure I understand you. Clojure code is “just data” so you can execute Clojure using Clojure. You don’t need an API for that. Could you explain what you are trying to do? Do you just need the eval function perhaps?


#5

chibi scheme can be embedded into C programs. A C program can embed chibi scheme interpreter and inject C functions into it. The interpreter has access only to those injected C functions.

Another example is https://github.com/hexchat/hexchat-addons which contains addons that have access to hexchat plugin API. Those hexchat addons don’t have full access to all C functions and variables.

I want to inject namespaces into interpreted clojure scripts which will not have access to other namespaces.

I know there have been attempts to create clojure sandbox which all ceased to continue years ago.