Re: uriGetter encoding

Thomas Leonard <tal-v5nx5w6akNyLE8xUarVfuPLx9OUvmyODWmv/[email protected]>
Newsgroups gmane.comp.lang.e.general
Organization IT Innovation
Message-ID <[email protected]>
On Wed, 2010-06-23 at 08:32 -0700, Kevin Reid wrote:
[...]
> It is my opinion that if we're going to use URL notation, we had  
> better use URL syntax, and <file:///%20> means the file named unixly  
> "/ ", and if you want something else you had better not use angle  
> brackets and colons.
> 
> I agree that the issue of what "get" should mean is in general not  
> clear.
> 
> Hm.
> 
> Complicated option: the <a:b> notation expands to, not
>    <a>["b"]
> but
>    <a>[makeURLText("b")]
> 
> That is, we still use get/1, but label the key being looked up as  
> being not a String but a URLText, which is just a String wrapped in a  
> distinct type (which coerces to String so such distinctions can be  
> ignored when desired). Then all filesystem lookups can treat URLText  
> as %20 -> " " but treat String literally.
> 
> I rather like this idea I just invented: it is a marginal step away  
> from the hazards of untyped string data and what-escaping-level-is- 
> this. But it might be too arcane for users. Thoughts?

Well, I like it. I've used separate types for encoding strings before
and it works well to prevent subtle escaping bugs. I assume there would
be a guard for methods that need an encoded string? e.g.

? def encoded := "a b" :URIFragment
# value: URIFragment("a%20b")

? encoded :String
# value: "a b"

I was a bit worried about backwards compatibility, but maybe the
coercion fixes that. Or, we could use the syntax version to turn it on.
Coercing to a String and back would be slightly lossy (using your
example of %26 = "&"). Is that OK?


? def encoded := "&a%26b" :URIFragment
# value: URIFragment("&a%26b")

? encoded :String
# value: "&a&b"

? (encoded :String) :URIFragment
# value: URIFragment("&a&b")


-- 
Dr Thomas Leonard
IT Innovation Centre
2 Venture Road
Southampton
Hampshire SO16 7NP

Tel: +44 0 23 8076 0834
Fax: +44 0 23 8076 0833
mailto:tal-v5nx5w6akNyLE8xUarVfuPLx9OUvmyODWmv/[email protected]
http://www.it-innovation.soton.ac.uk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.