Modules are the enclosing unit of our building blocks. They are the super block to which functions are the blocks. But occasionally, we wish to get data about our modules and metadata on our building blocks. We would probably like to document our code. We would like those following us to be able to read those comments and documentation. Better yet, we would like to have nice tooling around building rich documentation about our code while minimizing duplication, if not entirely eliminating it. Or, instead of documentation, we would like to tag our modules and functions with certain attributes that we could later use for any other number of reasons.
To support these goals, Elixir gives us the ability to give modules attributes, which we can use as developers, or users, or they can be used by the VM. Similarly, we can use attributes as constants.
Attributes are defined in Elixir as @name
. For example, I could add the @vsn
attribute to annotate a module named MyModule
...