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
- Host: GitHub
- URL: https://github.com/hauntedhost/using
- Owner: hauntedhost
- Created: 2017-06-20T04:10:44.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-20T04:14:20.000Z (almost 9 years ago)
- Last Synced: 2025-08-10T08:53:15.513Z (10 months ago)
- Language: Elixir
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.