elixir-lang/elixir — pull request #366 by alco (2012-06-14 18:17:13+00:00)
Title: Map device name in runtime to save some typing

Here's my take on the issue #318. I ran into a compiler crash when placing the `defmacrop` part at the bottom of the module.

```
elixir/lib/io.ex:114: macro map_dev/1 is unused
error: {'__MAIN__.CompileError','__exception__',
<<"function map_dev/1 undefined">>,
<<"/Users/alco/Documents/git/elixir/lib/io.ex">>,
19}
stacktrace: [{io,'__info__',[macros],[]},
{elixir_dispatch,get_optional_macros,1,
[{file,"src/elixir_dispatch.erl"},{line,225}]},
{elixir_dispatch,expand_require,8,
[{file,"src/elixir_dispatch.erl"},{line,135}]},
{elixir_dispatch,dispatch_require,6,
[{file,"src/elixir_dispatch.erl"},{line,83}]},
{lists,mapfoldl,3,[{file,"lists.erl"},{line,1278}]},
{elixir_clauses,assigns_block,6,
[{file,"src/elixir_clauses.erl"},{line,44}]},
{elixir_def,translate_definition,7,
[{file,"src/elixir_def.erl"},{line,165}]},
{elixir_def,store_definition,8{"init terminating in do_boot",1}
,
[{file,"src/elixir_def.erl"},{line,81}]}]
```

Also, I tried to make a wrapper for `def` to streamline the mapping experience, but got stuck with unquoting and concatenating module refs. Not sure if it's of any use:

```elixir
defmacrop ErlIO(fun, dev, args) do
quote do
Erlang.io.unquote(fun) unquote(map_dev(dev)), unquote_splicing(args)
end
end
```