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

Call-site macro #45

Open
carstenbauer opened this issue Nov 19, 2023 · 4 comments · May be fixed by #54
Open

Call-site macro #45

carstenbauer opened this issue Nov 19, 2023 · 4 comments · May be fixed by #54

Comments

@carstenbauer
Copy link
Member

carstenbauer commented Nov 19, 2023

Came up on discourse.

Would be nice to have a macro that is similar to @code_* and others and that can be used like

@check_allocs multiply(rand(10,10), rand(10,10))

rather than having to augment the method definition (and run the allocation check on every call). I assume this is straightforward given that there already is the check_allocs function that works on the function signature alone.

@jariji
Copy link

jariji commented Nov 19, 2023

@check_allocs multiply(rand(10,10), rand(10,10))

What is that expression supposed to say about the allocations in rand(10, 10)? Is there supposed to be a $ escape or setup= like in BenchmarkTools.@benchmark?

@carstenbauer
Copy link
Member Author

Nothing. Similar to @code_* it is only supposed to analyze the method itself. It should figure out the function signature from the given argument values, but that's it. Hence there is no need for interpolation syntax IMO.

@topolarity
Copy link
Member

Just to round out the discussion, I wanted to point out #49 which is relevant for some of use cases mentioned on Discourse

If you need hard guarantees that some code is allocation-free, then right now you (unfortunately) have to go through the @check_allocs entry point.

That said, a call-site macro sounds like a fine idea to me 👍

@tecosaur tecosaur linked a pull request Nov 21, 2023 that will close this issue
@gdalle
Copy link

gdalle commented Oct 15, 2024

Hi there! I just started using AllocCheck and it is very neat.
I think the feature suggested here would make it even better, because I always end up doing the following, which is a bit clumsy

check_allocs(f, typeof.((x, y, z)))

Just a friendly encouragement to anyone working on the call site macro, your work will not be in vain!

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 a pull request may close this issue.

4 participants