Attributes

Module attributes have the syntax -AtomTag(...) and are used to define certain properties of a file. (Note: -record(...) and -include(...) have a similar syntax but are not considered module attributes.) There are two types of module attributes: predefined and user-defined.

Predefined Module Attributes

The following module attributes have predefined meanings and must be placed before any function definitions:

-module(modname).

The module declaration. modname must be an atom. This attribute must be the first attribute in the file. Conventionally the code for modname should be stored in a file called modname.erl. If you do not do this, then automatic code loading will not work correctly; see Dynamic Code Loading for more details.

Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.