Michał Muskała
unread,Jul 15, 2016, 5:50:51 AM7/15/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to elixir-l...@googlegroups.com
Hello everybody.
IO.inspect/2 is one of the most useful debugging tools, and I use it extremely often. The ability to stick `|> IO.inspect` in pretty much every part of the program is really powerful. Unfortunately when having multiple such calls it becomes hard to distinguish which output matches which call.
The usual way to solve this is by inspecting something like {tag_name, value} instead of just value, but this has the unfortunate effect of breaking the pipe-ability and forces you to assign things into specific variables.
I propose we add an option to IO.inspect called tag. It would simply print the tag before the output. How would it look like?
IO.inspect([1, 2, 3], tag: “my list”)
would print:
my list => [1, 2, 3]
The return value would obviously not change, so it would still be a list [1, 2, 3] in that case. This still allows IO.inspect to be pipe-able and gives us easily distinguishable output at the same time. I think this would streamline the debugging experience and make IO.inspect even more powerful.
Michał.