Well, yea, it's debatable whether Java's String is final for a good
reason or not.

About concatenation. I just added a test for that. new Uri('...') +
'string' and 'string' + new Uri('...') both work as expected. So
assuming it is two strings being concatenated it will work anyway. You
can also use it to test a regexp: (/^...$/).test(new Uri('...'))

So I guess we're down to whether or not the String-manipulation
methods such as substr, replace etc. are needed. And that boils down
to whether or not a URI is a String?

IMO, it isn't. Same as the DOM isn't a giant HTML string. Now an e-
mail would probably be sent around as a string in it's serialized
form. But if we're going to do manipulations on it, I don't think it's
a string anymore. Same as we (usually) don't do manipulations on HTML
as strings but we do pass around serialized HTML when we don't have to
manipulate it.


On Mar 11, 3:47 am, Guillermo Rauch <[email protected]> wrote:
> It's more of a design choice. I'm still not completely sold on it being a
> standalone Class. Java declares String as final, which is why the URI is
> completely separate. But if we have the chance to subclass String, it's
> worth considering.
> As it's been pointed out, the question now is: is an URI a String? or its
> unique formation sets it apart ?
>
> It's clear that inheriting String methods offers no advantage, and the only
> other advantage is that it gets String treatment if you want to pass it
> along to other functions that expect one (think concatenation for example).
>
> On Wed, Mar 11, 2009 at 12:39 AM, Thomas Aylott <
>
>
>
> [email protected]> wrote:
>
> > So, what are the pros/cons of it being a Class or a String subclass?
>
> > btw, It it's a String subclass, then it should be String.URI.
>
> > Why can't we have both a String.URI Native and a proper URI class?
> > String.URI could easily just use URI internally.
>
> > —Thomas Aylott / subtleGradient
>
> > On Mar 10, 2009, at 7:07 PM, nutron wrote:
>
> >  Anyone else have any thoughts?
>
> --
> Guillermo Rauchhttp://devthought.com

Reply via email to