Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make defnp support multi-arity functions #75

Merged
merged 1 commit into from
Aug 14, 2014

Conversation

maurolopes
Copy link
Contributor

I have implemented support for multi-arity functions in the defnp macro, which previously resulted in a compile error.
When shown in the profiling report, the name of the function gets a suffix "_x", where x is the arity. This happens only in the multi-arity case. For example:

(defnp f
    ([x] (reduce + (range x)))
    ([] (f 123)))

creates two lines in the report, namely f_1 and f_0.

@ptaoussanis
Copy link
Member

Hi Mauro, that looks great - thanks a lot!

Is this code borrowed from somewhere? Any idea how robust it is? Will try take a look in detail in the next few days then get back to you on merging.

Cheers! :-)

@maurolopes
Copy link
Contributor Author

Hi Peter,

It is not borrowed. I wrote it myself based on your own defnp
implementation :)

I used that function name-with-attributes to parse correctly the function
name, docstring and metadata, so this should be ok.

Also, I tested functions with one and multiple arities, with and without
prepost maps, so I think everything is working.

Note that declaring a function with an extra pair of parentheses around the
arguments and the body, as in (def f ([x](inc x))), makes my code consider
it multi-arity, reporting as f_1, but I think that is ok.

Cheers!

Mauro

On Thursday, August 7, 2014, Peter Taoussanis notifications@github.com
wrote:

Hi Mauro, that looks great - thanks a lot!

Is this code borrowed from somewhere? Any idea how robust it is? Will try
take a look in detail in the next few days then get back to you on merging.

Cheers! :-)


Reply to this email directly or view it on GitHub
#75 (comment).

ptaoussanis added a commit that referenced this pull request Aug 14, 2014
Make defnp support multi-arity functions (@maurolopes)
@ptaoussanis ptaoussanis merged commit 7e10cb9 into taoensso:dev Aug 14, 2014
@ptaoussanis
Copy link
Member

This seems to work well Mauro, thanks again!

@maurolopes
Copy link
Contributor Author

Cool, Peter.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants