Another reason for the tag is that you can use it in a pipeline. If I have long pipeline I am debugging I like to sprinkle some `|> IO.inspect` between the lines to see what's going on in each pipeline stage. And when piping it's of course not possible to wrap the value in a tuple.
Big +1 from me for this feature. On Fri, Jul 15, 2016 at 12:11 PM, Michał Muskała <[email protected]> wrote: > Ok, I will work on it. > > On 15 Jul 2016, at 12:07, José Valim <[email protected]> > wrote: > > Good points Andrea. Yes, let's ship this then. > > > > *José Valim* > www.plataformatec.com.br > Skype: jv.ptec > Founder and Director of R&D > > On Fri, Jul 15, 2016 at 12:00 PM, Andrea Leopardi <[email protected]> > wrote: > >> I love this feature, but I am against wrapping in a tuple because then >> you may wonder if you are inspecting a tuple or something with :tag. >> Instead, if you have "my list: ..." it will not be like any other inspected >> term, so very easy to understand. Wdyt? :) >> >> >> Andrea Leopardi >> [email protected] >> >> On Fri, Jul 15, 2016 at 11:57 AM, José Valim < >> [email protected]> wrote: >> >>> I like this suggestion. I am wondering though if the tagging should be >>> done by wrapping the input in a tuple: >>> >>> IO.inspect([1, 2, 3], tag: “my list”) >>> #=> {"my list", [1, 2, 3]} >>> >>> >>> If not, we should probably just print: "my list: [1, 2, 3]". >>> >>> >>> >>> *José Valim* >>> www.plataformatec.com.br >>> Skype: jv.ptec >>> Founder and Director of R&D >>> >>> On Fri, Jul 15, 2016 at 11:50 AM, Michał Muskała <[email protected]> >>> wrote: >>> >>>> 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ł. >>>> >>>> -- >>>> 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/E807B41E-B89A-43CD-B55D-60A742B55BBC%40muskala.eu >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >>> -- >>> 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/CAGnRm4%2BUhyhgMDdNy0gJk2Pm_eafm_n6SBViXmjiq8AWepEBeQ%40mail.gmail.com >>> <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BUhyhgMDdNy0gJk2Pm_eafm_n6SBViXmjiq8AWepEBeQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> -- >> 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/CAM9Rf%2BL60EKrTAaP0VZ%2BcsSnff5ffQuZVHOkS__qQdBTRmJi1Q%40mail.gmail.com >> <https://groups.google.com/d/msgid/elixir-lang-core/CAM9Rf%2BL60EKrTAaP0VZ%2BcsSnff5ffQuZVHOkS__qQdBTRmJi1Q%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > > -- > 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/CAGnRm4KMZhzMGNCjoTRahwwmQzfc%2BPN6qsCTG54vJp12jjR2rA%40mail.gmail.com > <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KMZhzMGNCjoTRahwwmQzfc%2BPN6qsCTG54vJp12jjR2rA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > > > -- > 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/A8797967-516A-408E-B4E5-C4E82794E184%40muskala.eu > <https://groups.google.com/d/msgid/elixir-lang-core/A8797967-516A-408E-B4E5-C4E82794E184%40muskala.eu?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Eric Meadows-Jönsson -- 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/CAM_eaphmmpawDYF0HUz%2Bq0pmbbw9zvPexoR6ofEeBbBpjKi3eA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
