An open API service indexing awesome lists of open source software.

https://github.com/hauntedhost/using

attempt to import helper functions into another module namespace
https://github.com/hauntedhost/using

Last synced: 9 months ago
JSON representation

attempt to import helper functions into another module namespace

Awesome Lists containing this project

README

          

# Using

I would like to import functions from one module into another module.

Given this code:

```elixir
defmodule Using do
use Using.Importer
end

defmodule Using.Importer do
defmacro __using__(_) do
quote do
import Using.Helpers
end
end
end

defmodule Using.Helpers do
def hello, do: "world"
def greeting(name), do: "hello #{name}"
end
```

I would expect to be able to call `Using.hello/0` and `Using.greeting/1` directly. But they are not in scope.