📎 Webclip
Hacking Elixir's Syntax
The post shows a small Elixir language change: support for underscores in binary, hex, and octal literals. The author finds the tokenizer in the Erlang part of the codebase, updates its patterns to ignore underscores, and checks the result with tests.
Reading notes#
- Elixir already supported underscores in decimal numbers, but not in binary notation.
- The codebase was easy to build with
make clean test. grepled to the tokenizer tests and then toelixir_tokenizer.erl.- The tokenizer has separate paths for hex, binary, and octal numbers.
- The
is_hex,is_bin, andis_octalchecks are macros defined inelixir.hrl. - The author first considered adding
_to the character checks, but instead added a pattern that drops underscores while parsing. - After the change,
make test_erlangpassed all tests. - A full
make clean testalso passed. - The author says the source layout was logical and the code was easy to understand.
- The post presents the existing test suite as what made it easy to find the relevant code.
- The change became a pull request, and a slightly different version was merged.
