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/8036a77f-f30e-43b1-94d3-61e2a1d993c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to