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

@memoize cannot handle unnamed arguments #88

Open
matthias314 opened this issue Nov 3, 2024 · 1 comment
Open

@memoize cannot handle unnamed arguments #88

matthias314 opened this issue Nov 3, 2024 · 1 comment

Comments

@matthias314
Copy link

matthias314 commented Nov 3, 2024

Simple example:

julia> @memoize f(::Int) = 1;

julia> f(1)
ERROR: MethodError: no method matching var"##f_unmemoized"(::Nothing)
The function `##f_unmemoized` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  var"##f_unmemoized"(::Int64)
   @ Main REPL[2]:1

A more realistic example is using Val:

julia> @memoize g(::Val{N}) where N = N;

julia> g(Val(1))
ERROR: MethodError: no method matching var"##g_unmemoized"(::Nothing)
The function `##g_unmemoized` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  var"##g_unmemoized"(::Val{N}) where N
   @ Main REPL[4]:1

EDIT: Underscores don't work, either:

julia> @memoize h(_::Val{N}) where N = N
ERROR: syntax: all-underscore identifiers are write-only and their values cannot be used in expressions around /usr/local/julia-depot/packages/Memoize/12ANR/src/Memoize.jl:62

I'm using Memoize v0.4.4.

@cstjean
Copy link
Collaborator

cstjean commented Nov 5, 2024

Yes, that's a limitation that wouldn't be so hard to fix. PR welcome!

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