Fluid Dynamics <[email protected]> writes:
>> (defn ^:private form-with-arity[n]
>> ;; left as an exercise for the reader
>> )
>>
>> (defmacro ^:private m-default-ontology
>> `(defn default-ontology
>> ~@(map form-with-arity (range 1 10))))
>>
>> (m-default-ontology)
>>
>> Or am I missing something more obvious?
>>
>> Phil
>>
>
> Well, the example case could be replaced with (def default-ontology
> dispatch). :)
Oh yes, that's true! Or rather I missed out some critical information.
The function is actually variadic, so there is a final, fall back
function of this form:
([f a b c & args]
(do-something-different-with-apply f a b c args))
Also (although you can't tell from the information given), dispatch is a
macro, so (def default-ontology dispatch) changes the semantics quite a
lot!
> Beyond that, you might want to consider generating such repetitive and
> predictably-structured functions with a custom def-something style macro,
> but it looks like you already are.
Another possibility would be to use a macrolet, which would reduce some
of the cruft I guess. Or even
(eval
`(defn stuff
~@(map...)))
Phil
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.