Hi,
On Jan 10, 7:45 am, Tom Faulhaber tomfaulha...@gmail.com wrote:
Actually this is possible. (seehttp://xkcd.com/386/)
I still don't think it's possible. You just modify the Var to contain
a different object, which proxies to the original one. This is
basically what I suggested - just a
Here's some (simpler?) code that will work for adding arity to
existing functions - http://gist.github.com/273401
It doesn't handle adding variable-arity (ie multiple arity using ) to
existing functions, but can add specific arity to existing varibale-
arity functions
It also doesn't handle
Yup, this version would cover most cases in a simpler way. My goal
(for no particular reason except it entertained me) was to make
something that worked as much like defn as possible. Most of the
complexity is because of handling the possible combinations of arities
that we might see as a result:
Suppose I already have a function f that accepts 0 and 1 param:
(defn f
([] 0)
([ _ ] 1))
How do I extend it with additional version that takes 2 params?
Something like the following that does not override the original:
(defn f [ _ _ ] 2)
and makes all 3 work:
(f)
(f 1)
(f 1 2)
- Dmitry
--
Hi,
Am 09.01.2010 um 09:59 schrieb Dmitry Kakurin:
Suppose I already have a function f that accepts 0 and 1 param:
(defn f
([] 0)
([ _ ] 1))
How do I extend it with additional version that takes 2 params?
Something like the following that does not override the original:
(defn f [ _
Actually this is possible. (see http://xkcd.com/386/)
See the macro add-arity which I've put up here: http://gist.github.com/273349
This allows you to do things like:
user (add-arity keyword [ns name suffix] (keyword ns (str name -
suffix)))
#user$eval__6304$fn__6309