[racket-dev] Can get-pure-port's signature be expanded to consume strings too?

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Oct 5 18:28:39 EDT 2012

6 hours ago, Danny Yoo wrote:
> I keep finding myself writing:
>     (get-pure-port (string->url ...))
> where the call to get-pure-port always has a string->url there.  I was
> wondering if something like the following patch would be acceptable:
>     https://github.com/dyoo/racket/commit/3aa1467a168be758c20e36ee7afad190f3af0ad0

+1 (modulo some stylistic choices...)

I've wanted to do that in the past a few times -- since I think that
most uses of the `net/url' functions are with a string that is
immediately converted to a URL, resulting in unnecessary verbosity.
But I vaguely remember that there was some objection to it.


This comes in addition to the frequently raised issue where
`string->url' is trying hard to parse the URL but it would be better
to do that lazily, since in almost all of these cases the URL is only
used to re-construct a string later on, which is usually the same.
And there are some obscure cases where they're not the same, which has
lead to problems many times -- including the notorious issue of "&" vs
";", which would disappear almost completely if the original URL
string was kept.


          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the dev mailing list.