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

Can’t use cache as a keyword argument for memoized function #28

Closed
Socob opened this issue Jun 14, 2023 · 0 comments
Closed

Can’t use cache as a keyword argument for memoized function #28

Socob opened this issue Jun 14, 2023 · 0 comments

Comments

@Socob
Copy link

Socob commented Jun 14, 2023

For some reason I feel like I’ve seen this mentioned before, but can’t find it now (maybe I saw it in the code?). Anyway, using cache as a keyword argument for a memoized function doesn’t work as expected and should probably throw an error if that’s possible:

julia> using Memoization

julia> @memoize f1(x; cache=(; abc="xyz")) = println("$x, $cache")
f (generic function with 1 method)

julia> f1(111)
111, IdDict{Any, Any}()

julia> f1(111; cache=(; abc="xyz"))

julia> @memoize f2(x; cache) = println("$x, $cache")
f2 (generic function with 1 method)

julia> f2(111, cache=(; abc="xyz"))
111, IdDict{Any, Any}()

julia> g(x; cache=(; abc="xyz")) = println("$x, $cache")
g (generic function with 1 method)

julia> g(111)
111, (abc = "xyz",)

If it’s not possible to detect this and throw an error for some reason, it should at least be documented.

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

1 participant