When to use period in elixir module name?

I saw elixir modules named like this:

defmodule Foo.bar.baz do
end

But I can not find the documentation indicating when to do this.

Is this related to subdirectories? Using mix, I can put my modules in subdirectories in the lib folder, and they work fine without dots.

For instance:

# this is in /lib/foo/bar

defmodule Bar do
end

What is an agreement?

+4
source share
2 answers

There is nothing special about .. You can give the module any name you want as long as it is a real atom, including, for example, whitespace:

iex(1)> defmodule :"hello world!!!" do
...(1)>   def hi, do: :ok
...(1)> end
iex(2)> :"hello world!!!".hi
:ok

, /, . .ex lib, iex.

, , , lib, . , lib/foo/bar/baz.ex Foo.Bar.Baz.

+6

, / MyApp.MyModule ( , / MyApp.) java com.example.blah....

/.

Elixir ( , String.Chars.)

/ , .

BTW, . - , , - . Module.concat/{1,2} , .

+3

Source: https://habr.com/ru/post/1695583/


All Articles