Skip to content

Instantly share code, notes, and snippets.

@MonkeyIsNull
Created February 11, 2015 01:43
Show Gist options
  • Save MonkeyIsNull/8e96bf7bf52f237a1291 to your computer and use it in GitHub Desktop.
Save MonkeyIsNull/8e96bf7bf52f237a1291 to your computer and use it in GitHub Desktop.
Presenter
defmodule Preso do
# shows what was passed in and then evals it and shoves the
# lhs back into the current context
defmacro show(stuff) do
{op, _, [{lhs,_, _}, rhs]} = stuff
IO.write "#{IO.ANSI.blue}#{IO.ANSI.bright}"
IO.write "#{lhs} #{op} "
IO.inspect rhs
IO.puts "#{IO.ANSI.reset}"
quote do
# export it back to the callers context
var!(ret) = unquote(stuff)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment