Re: How do I extend an existing function to take different number of params?

2010-01-11 Thread Meikel Brandmeyer
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

Re: How do I extend an existing function to take different number of params?

2010-01-10 Thread Amit Rathore
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

Re: How do I extend an existing function to take different number of params?

2010-01-10 Thread Tom Faulhaber
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:

How do I extend an existing function to take different number of params?

2010-01-09 Thread 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 [ _ _ ] 2) and makes all 3 work: (f) (f 1) (f 1 2) - Dmitry --

Re: How do I extend an existing function to take different number of params?

2010-01-09 Thread Meikel Brandmeyer
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 [ _

Re: How do I extend an existing function to take different number of params?

2010-01-09 Thread Tom Faulhaber
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