I use IO.inspect(binding()) a lot.

Although I don't think IO.inspect_vars would be a thing since it would need
to be a macro and having to require it before would probably lose its
appeal (and we don't plan to require anything other than Kernel by default).



*José Valimwww.plataformatec.com.br
<http://www.plataformatec.com.br/>Founder and Director of R&D*

On Sat, Oct 14, 2017 at 5:44 AM, Myron Marston <[email protected]>
wrote:

> IO.inspect has long been my go-to technique for troubleshooting code that
> isn’t quite working how I would expect. Since the :label option was added
> in 1.4, I use that all the time, too. The majority of the time, I use it to
> inspect one or more variables like so:
>
> IO.inspect(foo, label: "foo")IO.inspect(bar, label: "bar")
>
> However, I often find my self making simple, dumb mistakes when setting
> this up, such as copying and pasting a prior IO.inspect line, but
> forgetting to update the label, e.g.:
>
> IO.inspect(foo, label: "foo")IO.inspect(bar, label: "foo") # woops, the 
> output will label this as `foo`, too!
>
> Given how common this pattern is, it would be really nice if there was a
> function or macro to do this for us. I’m thinking something like:
>
> # inspect each variable in the current scope, labeling each with its 
> nameIO.inspect_vars(:all)
> # inspect just the provided variables, labeling eachIO.inspect_vars([foo, 
> bar])
> # inspect all variables in the current scope, except the provided ones, 
> labeling eachIO.inspect_vars(except: [foo, bar])
>
> I can also imagine it supporting a label option, to put a title above the
> list of variables, in order to distinguish multiple variable reports.
>
> Would others find this as useful as I would? Is there interest in it being
> added to Elixir?
>
> Thanks!
> Myron
> ​
>
> --
> 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/fd0d67af-3b5f-4ee9-b067-
> 8b263ccd1666%40googlegroups.com
> <https://groups.google.com/d/msgid/elixir-lang-core/fd0d67af-3b5f-4ee9-b067-8b263ccd1666%40googlegroups.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/CAGnRm4KSmcNtff772p2vhepaqEHhTMuz0ntMU%2BX8U5L6Mukg3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to