Created
May 16, 2014 17:04
-
-
Save alco/b59aa8293356aae5351d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
λ iex my.ex | |
Erlang/OTP 17 [erts-6.0] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace] | |
Interactive Elixir (0.13.3-dev) - press Ctrl+C to exit (type h() ENTER for help) | |
iex(1)> use My | |
nil | |
iex(2)> 3&&4 | |
81.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule My do | |
defmacro __using__(_) do | |
quote do | |
# import all macros from My | |
import unquote(__MODULE__) | |
# hide macros from Kernel | |
import Kernel, except: [&&: 2] | |
end | |
end | |
defmacro left && right do | |
:math.pow(left, right) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment