[e-lang] uriGetter encoding
tal at it-innovation.soton.ac.uk
Mon Jun 28 06:12:52 PDT 2010
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
> Complicated option: the <a:b> notation expands to, not
> 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
Hampshire SO16 7NP
Tel: +44 0 23 8076 0834
Fax: +44 0 23 8076 0833
mailto:tal at it-innovation.soton.ac.uk
More information about the e-lang