Implement Sigil in Elixir

Dunya Kirkali
2 min readDec 8, 2021

Sigil’s in Elixir is an extremely powerful construct which contributes greatly to developer productivity.

Some of the well know sigils are

Regex
Date
Time

But have you ever wondered how you can implement your own sigil?

Recently, José Valim held a live stream on Twitch where he solved Day 4 of Advent of Code. At the end of his stream (in the section he called it his “ramblings”) he explained how sigils can be implemented.

This article is so that I get to practice his teachings by applying them on a chess game I’ve been working on.

Context

Let’s imagine that we have the following struct to represent a chess board with all it’s pieces

As can be seen in the setup functions, it would be difficult to initialize a chess board using all of it’s pieces.

--

--

Dunya Kirkali
Dunya Kirkali

Written by Dunya Kirkali

I'm an engineering manager passionate about empowering engineers to deliver exceptional work through collaboration and innovation.

No responses yet