Along with all the fun, creative stuff
it enables you to do,
programming sometimes requires you to carry out
boring and repetitive editing operations.
If those operations are uniformly applicable,
it's straightforward to automate them
using regular expressions
and a tool like sed,
or :%s/foo/bar/g in vim-speak.
But sometimes a regex can't express
the pattern you want to match against
and on those occasions,
vim macros can come to the rescue.
Recently I wrote
about how Rust macros
make it easy to refactor repetitive code
that might otherwise become annoying
in a strongly-typed language.
Continuing the theme from that post,
I've noticed another use case
where macros can be beneficial:
writing custom assertions in tests.
Refactoring boilerplate code is always easy
in dynamically-typed languages,
but sometimes takes a bit more effort
when constrained by strong typing.
This is something I was puzzling over recently,
when the penny dropped for me
about how Rust's macros
can be used to bridge the gap.