I am new to meta programming . I have a module like this
defmodule transport do
use Qber.Web, :status
some[some_option]
end
In my web.ex
. I have define this status
like this:
def status do
quote do
use Qber.Status
end
end
This is my status module
defmodule Qber.Status do
@moduledoc """
"""
defmacro __using__(_options) do
quote do
code
end
end
defmacro some(options) do
quote do
options = unquote options
IO.inspect options
end
end
end
When i use Qber.Web,:status.its working fine but I also want to send the value from some
to the macro in the status module right now its giving error some
undefined in transport. How can i do this?
It's hard to tell what you are trying to do exactly without some more context.
However, use
doesn't import functions or macros, try adding import
:
defmodule Qber.Status do
defmacro __using__(_options) do
quote do
import Qber.Status
code
end
end
defmacro some(options) do
quote do
options = unquote options
IO.inspect options
end
end
end
Also, it's worth repeating what José said in the comments :
It is best if you state which problem you are trying to solve, since meta-programming is rarely the answer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.