Pass module to a macro

By using bind_quoted you are giving up control about when exactly the parameter gets expanded. In most cases you can ignore this fact, but sometimes expanding has side effects which you dont want to have.

defmodule Foo do
  defmacro unless(cond, [do: branch, else: other_branch]) do
    quote bind_quoted: [cond: cond, branch: branch, other_branch: other_branch] do
      if cond, do: other_branch, else: branch
    end
  end
end

require Foo
Foo.unless true do
  IO.puts "Branch"
else
  IO.puts "Other Branch"
end

This will probably not do what you want (perhaps there is even refinement necessary, since I have blindly typed without beeing able to do a testrun). This has already been discussed about 8 weeks ago in another thread and might give you some insights as well: