Hello,
This is a wide topic and I am going to illustrate it with one example from
ExUnit.
Sometimes when a test fails, especially when `%Plug.Conn{}` is one of the
arguments, in the stacktrace the reported function call is shown. The issue
is that when there is a big map/struct as an argument and a few other
arguments, it is very hard to see where one function argument ends and
another starts.
One approach to improve the experience in this case is to paint the
arguments in different colors.
Here is an artificial example that shows the problem.
Take a look at the %SomeModule.three_arg_function/3 function that takes 3
arguments - %Plug.Conn{}, map and %Plug.Conn{}.
Without any visual distinction in the terminal you would see something like
this: https://ibb.co/NnqMc1T
But if we throw some colors in, the arguments are clearly distinguished:
https://ibb.co/NnXYfcn
This ability to better visually distinguish the arguments can be applied in
a wide variety of situations and not only in the ExUnit stacktrace. The
problem can be solved in different ways that can be applied either
separately or combined. One such another "trick" I use to better understand
what happens is to copy the function header in a file and replace `\n` with
actual new lines.
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/d984f624-9aa9-43c1-b553-f6a9883259dcn%40googlegroups.com.