Skip to content

Commit 28734f0

Browse files
committed
Clarify aliases is part of the next chapter, closes #15401
1 parent 0dd4399 commit 28734f0

1 file changed

Lines changed: 5 additions & 22 deletions

File tree

‎lib/elixir/pages/getting-started/modules-and-functions.md‎

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@ end
212212

213213
The example above will define two modules: `Foo` and `Foo.Bar`. The second can be accessed as `Bar` inside `Foo` as long as they are in the same lexical scope.
214214

215-
If, later, the `Bar` module is moved outside the `Foo` module definition, it must be referenced by its full name (`Foo.Bar`) or an alias must be set using the `alias` directive discussed above:
215+
> #### Module names are isolated {: .info}
216+
>
217+
> You don't have to define the `Foo` module before defining the `Foo.Bar` module, as they are effectively independent.
218+
219+
If, later, the `Bar` module is moved outside the `Foo` module definition, it must be referenced by its full name (`Foo.Bar`) or an alias must be set using the `alias` directive, which we will learn in the next chapter:
216220

217221
```elixir
218222
defmodule Foo.Bar do
@@ -223,24 +227,3 @@ defmodule Foo do
223227
# Can still access it as `Bar`
224228
end
225229
```
226-
227-
> #### Module names are isolated {: .info}
228-
>
229-
> You don't have to define the `Foo` module before defining the `Foo.Bar` module, as they are effectively independent.
230-
231-
Aliasing a module only alias a single module, it doesn't alias any of its parents. Consider the following example:
232-
233-
```elixir
234-
defmodule Foo do
235-
defmodule Bar do
236-
defmodule Baz do
237-
end
238-
end
239-
end
240-
241-
alias Foo.Bar.Baz
242-
# The module `Foo.Bar.Baz` is now available as `Baz`
243-
# However, the module `Foo.Bar` is *not* available as `Bar`
244-
```
245-
246-
As we will see in later chapters, aliases also work well with macros, to guarantee they are hygienic.

0 commit comments

Comments
 (0)