I'm trying to get to know what modules are in Elixir. Because in Erlang they're just atoms, but in Elixir atoms start with :
character.
So I've checked these expressions in iex:
iex(16)> is_atom(List)
true
iex(17)> is_atom(:List)
true
iex(18)> List == :List
false
iex(19)> a = List
List
iex(20)> b = :List
:List
So it's pretty clear that both List
and :List
are atoms. However, how does it work on Erlang interop layer? Because Erlang's ok
is equal to Elixir's :ok
.
So which one of these two (List
and :List
) is equal to 'List'
in Erlang?
Atom is a special string-like data-type that is most commonly used for interfacing with code written in other BEAM languages such as Erlang and Elixir. It is preferable to define your own custom types to use instead of atoms where possible.
__MODULE__ is a compilation environment macros which is the current module name as an atom.
Interactive Elixir (1.0.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> List == :List
false
iex(2)> List == :'Elixir.List'
true
All uppercase atoms in Elixir automatically receive the Elixir.
prefix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With