I love tabular code.
This
defp decode(addr_t(:ind), _dest, data) do
case data do
<<0::6, data::bits>> -> {:t_data_ind, nil, data}
<<0b01::2, seq::4, data::bits>> -> {:t_data_con, seq, data}
<<0b1000_0000::8>> -> {:t_connect, nil, <<>>}
<<0b1000_0001::8>> -> {:t_discon, nil, <<>>}
<<0b11::2, seq::4, 0b10::2>> -> {:t_ack, seq, <<>>}
<<0b11::2, seq::4, 0b11::2>> -> {:t_nak, seq, <<>>}
_ -> {:error, :invalid_tpci}
end
end
for me, is just way more readable than
defp decode(addr_t(:ind), _dest, data) do
case data do
<<0::6, data::bits>> -> {:t_data_ind, nil, data}
<<0b01::2, seq::4, data::bits>> -> {:t_data_con, seq, data}
<<0b1000_0000::8>> -> {:t_connect, nil, <<>>}
<<0b1000_0001::8>> -> {:t_discon, nil, <<>>}
<<0b11::2, seq::4, 0b10::2>> -> {:t_ack, seq, <<>>}
<<0b11::2, seq::4, 0b11::2>> -> {:t_nak, seq, <<>>}
_ -> {:error, :invalid_tpci}
end
end
but I know, that most people don’t like it, so it will never be possible to format Elixir-code like that. And that is a good thing. It’s important to have a common code style everyone can read. So I keep formatting my C files in crazy ways, because in C, everybody complains about your style anyway and there will never be any agreement.