As a side project I'm creating a Clojure DSL for image synthesis (clisk).
I'm a little unsure on the best approach to function naming where I have functions in the DSL that are analogous to functions in Clojure core, for example the +
function or something similar is needed in my DSL to additively compose images / perform vector maths operations.
As far as I can see it there are a few options:
- Use the same name (
+
) in my own namespace. Looks nice in DSL code but will override the clojure.core version, which may cause issues. People could get confused. - Use the same name but require it to be qualified (
my-ns/+
). Avoids conflicts, but prevents people fromuse
ing the namespace for convenience and looks a bit ugly. - Use a different short name e.g. (
v+
). Can beuse
d easily and avoid clashes, but the name is a bit ugly and might prove hard to remember. - Use a different long name e.g. (
vector-add
). Verbose but descriptive, no clashes. - Exclude
clojure.core/+
and redefine with a multimethod+
(as georgek suggests).
Example code might look something like:
(show (v+ [0.9 0.6 0.3]
(dot [0.2 0.2 0]
(vgradient (vseamless 1.0 plasma) ))))
What is the best/most idiomatic approach?