I do the same when I’m using a standalone `IO.inspect`, but the proposal
here would help most with a _pipelined_ inspect (`foo |>
IO.inspect("label")`).I’m still not sure that the positive of using a string to avoid compile errors outweighs the inconsistency and resulting complexity, but that’s where I would want it because that’s where I have this problem most frequently. -a On Fri, Apr 23, 2021 at 12:10 PM Aaron Ross <[email protected]> wrote: > You can save a few more keystrokes by just adding a label to the inspect > payload: > > IO.inspect(my_var: foo) > > I end up inspecting a map pretty often, when I want to see multiple values > at once > > IO.inspect(%{foo: foo, bar: bar}) > > On Fri, Apr 23, 2021 at 7:24 AM Leandro Cesquini Pereira < > [email protected]> wrote: > >> Using an atom instead of a string will save you some time: >> IO.inspect(foo, label: :my_var) >> >> Not so direct as an app-level helper but easier to write than a string :) >> >> On Friday, April 23, 2021 at 2:34:56 AM UTC-4 [email protected] wrote: >> >>> Thanks for your feedback folks. I see where you are coming from and I >>> can not disagree. 😄 >>> >>> > Maybe it makes more sense for an application-level helper? >>> >>> Correct. I will do that going forward. 👍 >>> >>> - Faisal >>> >>> On Thursday, April 22, 2021 at 2:15:15 PM UTC-4 [email protected] >>> wrote: >>> >>>> > From a developer consistency perspective, though, I’m not as sold on >>>> this. >>>> >>>> I tend to agree, this feels like nice parameter sugar but makes it >>>> harder to interface consistently with extended options. Maybe it makes more >>>> sense for an application-level helper? >>>> >>>> On Thursday, April 22, 2021 at 7:14:59 AM UTC-7 [email protected] >>>> wrote: >>>> >>>>> Every time I forget to add the `label: ` and get a compile error >>>>> (which is *often*), I agree with you. From a developer consistency >>>>> perspective, though, I’m not as sold on this. With this convenience, >>>>> people >>>>> may forget to switch back to the keyword list when they need to add other >>>>> options like :limit, and try `IO.inspect(something, "Message", limit: >>>>> 300)`. >>>>> >>>>> -a >>>>> >>>>> On Wed, Apr 21, 2021 at 11:56 PM Faisal Alghurayri <[email protected]> >>>>> wrote: >>>>> >>>>>> Yes. 👍 >>>>>> >>>>>> I'm proposing: >>>>>> >>>>>> def inspect(item, message) when is_binary(message) do >>>>>> inspect(:stdio, item, label: message) >>>>>> end >>>>>> >>>>>> >>>>>> https://github.com/elixir-lang/elixir/blob/v1.11.4/lib/elixir/lib/io.ex#L421 >>>>>> >>>>>> The reason is just a small quality of life improvement. 😄 Please let >>>>>> me know what you think! >>>>>> >>>>>> - Faisal >>>>>> >>>>>> On Wednesday, April 21, 2021 at 11:42:53 PM UTC-4 [email protected] >>>>>> wrote: >>>>>> >>>>>>> There's already a label option in the docs: >>>>>>> >>>>>>> IO.inspect(1..100, label: "a wonderful range") >>>>>>> >>>>>>> On Thu, Apr 22, 2021 at 11:35 AM Faisal Alghurayri < >>>>>>> [email protected]> wrote: >>>>>>> >>>>>>>> Hello friends, >>>>>>>> >>>>>>>> Thank you for your great work in developing and maintaining Elixir. >>>>>>>> 🙌 >>>>>>>> >>>>>>>> I propose adding another signature to the IO.inspect/2 function >>>>>>>> where the second argument is a binary: >>>>>>>> >>>>>>>> IO.inspect(something, "This message should get shown in console") >>>>>>>> >>>>>>>> I think this is a small quality of life improvement since the >>>>>>>> developer won't need to explicitly pass the `label` option to see an >>>>>>>> associated message. >>>>>>>> >>>>>>>> Best Regards, >>>>>>>> Faisal >>>>>>>> >>>>>>>> -- >>>>>>>> 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/64793786-deea-4902-b450-39f53896c945n%40googlegroups.com >>>>>>>> <https://groups.google.com/d/msgid/elixir-lang-core/64793786-deea-4902-b450-39f53896c945n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>>>> . >>>>>>>> >>>>>>> -- >>>>>> 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/06452689-f476-456a-afeb-9a7fc58752abn%40googlegroups.com >>>>>> <https://groups.google.com/d/msgid/elixir-lang-core/06452689-f476-456a-afeb-9a7fc58752abn%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>> . >>>>>> >>>>> >>>>> >>>>> -- >>>>> Austin Ziegler • [email protected] • [email protected] >>>>> http://www.halostatue.ca/ • http://twitter.com/halostatue >>>>> >>>> -- >> 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/492ba85d-a8ad-4412-babb-05d97026a6d8n%40googlegroups.com >> <https://groups.google.com/d/msgid/elixir-lang-core/492ba85d-a8ad-4412-babb-05d97026a6d8n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > -- > *Aaron Ross* > [email protected] > https://aaronross.tech > > -- > 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/CAEZfmqXoMwvyu0yhshT7CZMYB6V7DJ14qr52p92B6_%3DBnH1L9w%40mail.gmail.com > <https://groups.google.com/d/msgid/elixir-lang-core/CAEZfmqXoMwvyu0yhshT7CZMYB6V7DJ14qr52p92B6_%3DBnH1L9w%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- Austin Ziegler • [email protected] • [email protected] http://www.halostatue.ca/ • http://twitter.com/halostatue -- 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/CAJ4ekQsgKmhEmm2jiHtbUOLYAuiQoyCrC%2BdmoUeAx15KpAFMAA%40mail.gmail.com.
