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

defmemo/defmemop suppresses compiler warnings #4

Open
tim2CF opened this issue Nov 26, 2018 · 3 comments
Open

defmemo/defmemop suppresses compiler warnings #4

tim2CF opened this issue Nov 26, 2018 · 3 comments

Comments

@tim2CF
Copy link

tim2CF commented Nov 26, 2018

example (Memoize 1.3.0) suppresses obvious compiler warnings

defmodule Greetings do
  use Memoize
  defmemo hello(name) when is_binary(name) do
    :ok = DoesNotExist.foo()
    "Hello, #{name}!"
  end
end
@tim2CF tim2CF changed the title defmemop suppresses compiler warnings defmemo/defmemop suppresses compiler warnings Nov 26, 2018
@melpon
Copy link
Owner

melpon commented Nov 26, 2018

I think Memoize uses Code.eval_quoted in __before_compile__/1, but I don't know how to fix it.

@tim2CF
Copy link
Author

tim2CF commented Nov 26, 2018

not use __before_compile__/1 ? :)

@eteeselink
Copy link

eteeselink commented Dec 13, 2018

I just ran into a problem that I suspect is related, so I'll report it here: Elixir warns about unused imports for functions only called from inside a defmemo:

defmodule Five do
  def five() do
    5
  end
end

defmodule Eleven do
  use Memoize
  import Five, only: [five: 0]

  defmemo eleven() do
    6 + five()
  end
end

yields a warning: unused import Five.

Unfortunately, I also don't know how to fix it :)
There has to be a way to tell Elixir to treat blocks of code passed to macros as, well, normal code, right? (I'm on Elixir 1.7.1, Erlang 20)

Thanks for an excellent library by the way. I really like how well memoize works with eg long-running computations or asynchronous operations. I looked at some of the source and I imagine that it wasn't easy to get that right. Hats off! I also like how you can gradually scale a memoize use case into a full blown cache, with expiry and all that.

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

3 participants