Or `URI["http://example.com"]` - all you need is to implement `Access` for 
atom which is actually trivial... The caveat with putting "function calls" 
as inspect representation is that it's not quite copy-pastable as literals 
because you can't use it in match clauses. But let's leave that discussion 
for a separate thread!

W dniu czwartek, 4 stycznia 2018 18:52:46 UTC+1 użytkownik OvermindDL1 
napisał:
>
> It could always print out to something like:
>
> ```elixir
> URI.parse("ponzi://example.com"
> ```
>
> Thus making the output format the thing needed to execute to recreate the 
> same structure.
>
>
> On Monday, January 1, 2018 at 9:33:47 AM UTC-7, Ben Wilson wrote:
>>
>> The downside here is that you can no longer copy and paste the output.
>>
>> On Monday, January 1, 2018 at 10:58:30 AM UTC-5, Wojtek Mach wrote:
>>>
>>> Hello,
>>>
>>> Having an Inspect implementation would make a shorter output in iex, 
>>> exunit diffs etc and the string representation is inambiguous. Under the 
>>> hood it would use `String.Chars.URI.to_string/1`.
>>> The only reason it might have been omitted that I can think of is how it 
>>> plays with `URI.default_port/2`:
>>>
>>> Before:
>>>
>>> iex(3)> URI.default_port("ponzi", 8080)
>>> :ok
>>>
>>> iex(4)> URI.parse("http://example.com:8080";)
>>> %URI{authority: "example.com:8080", fragment: nil, host: "example.com",
>>>  path: nil, port: 8080, query: nil, scheme: "http", userinfo: nil}
>>>
>>> iex(5)> URI.parse("ponzi://example.com:8080")
>>> %URI{authority: "example.com:8080", fragment: nil, host: "example.com",
>>>  path: nil, port: 8080, query: nil, scheme: "ponzi", userinfo: nil}
>>>
>>> iex(6)> URI.parse("ponzi://example.com")
>>> %URI{authority: "example.com", fragment: nil, host: "example.com", path: 
>>> nil,
>>>  port: 8080, query: nil, scheme: "ponzi", userinfo: nil}
>>>
>>>
>>>
>>> After:
>>>
>>> iex(2)> URI.default_port("ponzi", 8080)
>>> :ok
>>>
>>> iex(3)> URI.parse("http://example.com:8080";)
>>> #URI<http://example.com:8080>
>>>
>>> iex(4)> URI.parse("ponzi://example.com:8080")
>>> #URI<ponzi://example.com>
>>>
>>> iex(5)> URI.parse("ponzi://example.com")
>>> #URI<ponzi://example.com>
>>>
>>>
>>>
>>> so one could argue we lose a bit of information as the default port is 
>>> implicit. Was that the reason it was omitted? Otherwise, I'm happy to 
>>> prepare a PR.
>>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/3c57c25f-7b60-452f-a4f4-99ab15420847%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to