You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a variable is not used by a function or a clause, we add a leading underscore (`_`) to its name to signal this intent. This rule is also covered in our [Naming Conventions](../references/naming-conventions.md#underscore-_foo) document.
169
+
Function heads cannot have patterns nor guards. They may only define the argument names and their default values.
169
170
170
171
## Understanding Aliases
171
172
@@ -182,8 +183,7 @@ true
182
183
183
184
By using the `alias/2` directive, we are changing the atom the alias expands to.
184
185
185
-
Aliases expand to atoms because in the Erlang Virtual Machine (and consequently Elixir) modules are always represented by atoms. By namespacing
186
-
those atoms elixir modules avoid conflicting with existing erlang modules.
186
+
Aliases expand to atoms because in the Erlang Virtual Machine (and consequently Elixir) modules are always represented by atoms. By namespacing those atoms, Elixir modules avoid conflicting with existing Erlang modules.
187
187
188
188
```elixir
189
189
iex>List.flatten([1, [2], 3])
@@ -212,9 +212,7 @@ end
212
212
213
213
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.
214
214
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.
216
-
217
-
**Note**: in Elixir, you don't have to define the `Foo` module before being able to define the `Foo.Bar` module, as they are effectively independent. The above could also be written as:
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:
218
216
219
217
```elixir
220
218
defmoduleFoo.Bardo
@@ -226,7 +224,11 @@ defmodule Foo do
226
224
end
227
225
```
228
226
229
-
Aliasing a nested module does not bring parent modules into scope. Consider the following example:
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:
230
232
231
233
```elixir
232
234
defmoduleFoodo
@@ -241,4 +243,4 @@ alias Foo.Bar.Baz
241
243
# However, the module `Foo.Bar` is *not* available as `Bar`
242
244
```
243
245
244
-
As we will see in later chapters, aliases also play a crucial role in macros, to guarantee they are hygienic.
246
+
As we will see in later chapters, aliases also work well with macros, to guarantee they are hygienic.
0 commit comments