abreujp

abreujp OP

I’ve published a new article in my Elixir learning series on dev.to exploring module attributes - the compile-time annotations and constants that describe and configure our modules.

The article covers:

  • The three roles of module attributes: annotations, temporary storage, and compile-time constants
  • Setting and reading attributes, and how compile time differs from runtime
  • Using attributes as constants, including inside patterns and guards
  • Precomputing values at compile time and exposing them through functions
  • Documenting modules and functions with @moduledoc and @doc
  • Describing function contracts with @spec and typespecs
  • Defining custom types with @type, @typep, and @opaque
  • The @vsn, @derive, @behaviour, and @impl attributes
  • Registering custom attributes with Module.register_attribute/3 and accumulating values across the module
  • Practical guidelines for when to reach for an attribute instead of a plain function

With complete working examples you can copy into IEx, you’ll learn how module attributes become the glue between documentation, configuration, and compile-time behavior - and how they shape the Elixir code you read every day.

Check it out:

Where Next? Top

Trending in Blog Posts Top

bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
ryanzidago
Hi all, In this article, I make the case for each test owning its setup. Usually I forbid my AI agents to use the setup callbacks; I mu...
New
zorn
As I’ve leaned into AI code generation on LocalCents, the volume I ship has climbed, and my worry shifted from any single change to the l...
New
pckrishnadas88
This article demonstrates how to build a minimal stateful process using only Elixir’s core concurrency primitives: spawn/1, send/2, recei...
New
zorn
A recent ex_money v6 upgrade was blocked because Timex pins an old gettext. Rather than one big remove-and-rewrite PR, I used a shim: a m...
New
jola
Doing a little mini-series on distributed Elixir with some examples, starting with setting up your cluster and monitoring it. If you have...
New
smaller_infinity
I recently figured out how to the the Rust hotpath profiling crate running in an elixir benchmark script (for profiling NIFs). I had some...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New

We're in Beta

About us Mission Statement