A few Notes on the "Elixir in Action" book.

Chapters 1 & 2

  • The . indicator in modules does not actually create a hierarchical system of modules - it's just a syntactic sugar that helps to scope naming.

  • The Kernel module is called "kernel" because it supplies common functions across all modules (and is automatically imported into all modules for convenience).

  • Aliasing lets you rename a module you want to call out to (either implicitly or explicitly):

defmodule MyModule do
  alias Geometry.Rectangle as: Rect # << explicity
  # alias Geometry.Reactangle # << implicit: returns the last segment: Rectangle

  # ...

  def my_func do
    Rect.Area
  end
end
  • Module attributes are indicated by @. They can be used as constants or can be "registered" (example: @doc and @moduledoc)

  • Similarly, @spec is a module attribute and is used by dialyzer.

  • Atoms (ex: :an_atom) tend to be very memory efficient for named constants as the variables that holds one points to a location on the "atom table" and thus doesn't contain the entire text of an atom.

Chapter 3

Some really interesting notes here on matching and control flow. I wrote a post on things I learned about Streams.