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

Functional usage? #57

Open
tbenst opened this issue May 14, 2020 · 1 comment
Open

Functional usage? #57

tbenst opened this issue May 14, 2020 · 1 comment

Comments

@tbenst
Copy link

tbenst commented May 14, 2020

Thanks for this package! I'm looking for higher order function memoization, e.g. I'd like to be able to do: memoized_f = @memoize expensive_function_from_package, but this triggers ERROR: LoadError: @memoize must be applied to a method definition.

As a workaround, I currently do

@memoize function memoized_f(args...)
  expensive_function_from_package(args...)
end

But not sure that this is fully generic. Is this a fundamental restriction due to the function/method implementation?

@cstjean
Copy link
Collaborator

cstjean commented Oct 28, 2020

You mean that you would like to memoize a call? Like

function my_function()
   @memoize some_expensive_call(...)
end

? That's currently outside of the realm of this package, but it could be done I suppose if the macroexpansion looked up a cache in some global variable. Like get!(global_cache_dict, @__MODULE__, @__LINE__) or something.

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

No branches or pull requests

2 participants