Automatic inspect interpolation

59 views
Skip to first unread message

niahoo osef

unread,
Jul 29, 2017, 7:17:09 PM7/29/17
to elixir-lang-core
Hey, 

I would like to know what you would think about a new interpolation mechanism that automatically calls `inspect` as the `#{}` operator calls `to_string` ?

Just like `raise "bad value : #!{var}"` instead of `raise "bad value : #{inspect var}"` (The operator could be anything, I don't care)

Thanks.

José Valim

unread,
Jul 30, 2017, 3:31:57 AM7/30/17
to elixir-l...@googlegroups.com
I personally prefer the clearer approach of calling "inspect" instead of an operator.



José Valim
Skype: jv.ptec
Founder and Director of R&D

--
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 elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/7da7971b-5abb-4ed2-afb1-4add2b4e0dca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ben Wilson

unread,
Jul 30, 2017, 6:48:15 PM7/30/17
to elixir-lang-core, jose....@plataformatec.com.br
Agreed. Inspect can leak sensitive information easily, and I think it's important to annotate that a structure will be using its debug representation in a string.


On Sunday, July 30, 2017 at 3:31:57 AM UTC-4, José Valim wrote:
I personally prefer the clearer approach of calling "inspect" instead of an operator.



José Valim
Skype: jv.ptec
Founder and Director of R&D

On Sun, Jul 30, 2017 at 1:17 AM, niahoo osef <ludovic....@gmail.com> wrote:
Hey, 

I would like to know what you would think about a new interpolation mechanism that automatically calls `inspect` as the `#{}` operator calls `to_string` ?

Just like `raise "bad value : #!{var}"` instead of `raise "bad value : #{inspect var}"` (The operator could be anything, I don't care)

Thanks.

--
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 elixir-lang-co...@googlegroups.com.

niahoo osef

unread,
Jul 31, 2017, 5:47:41 PM7/31/17
to elixir-lang-core, jose....@plataformatec.com.br
Hi, thank you both.


Agreed. Inspect can leak sensitive information easily, and I think it's important to annotate that a structure will be using its debug representation in a string.

Good point ! 

I personally prefer the clearer approach of calling "inspect" instead of an operator.

I guess I'll have to take the habit :) My main concern is about debugging and structs. I see that the String.Chars protocol is not defined for Any, Maps. Everyone is free to implement a reasonable default for opaque types when MIX_ENV is dev. So it's good enough.
Reply all
Reply to author
Forward
0 new messages