Type to represent URIs?

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Jan 30 17:48:51 UTC 2019


On Wed, Jan 30, 2019 at 05:21:25PM +0000, Neia Neutuladh via Digitalmars-d wrote:
> On Wed, 30 Jan 2019 15:17:28 +0000, Jesse Phillips wrote:
> > I like std.path it does not use a path type and works directly off
> > strings. There are benefits to a path type, but I don't know if that
> > is enough.
> > 
> > So I think I would prefer a uri library doing the same thing.
> 
> I admit I didn't even consider that when writing urld. Now that I'm
> considering it, it seems like a tiny benefit in memory usage at a cost
> of having to re-parse large portions of the URL each time you want to
> manipulate it.
> 
> If you are only going to extract one part of a URL, it's better to use
> string everywhere. If you are going to manipulate a URL in several
> ways in a narrow section of code, you can use string at rest and in
> transit, then use the types provided by Vibe or urld only when you
> need to extract data or modify a URL. Or provide overloads for both,
> maybe.

This is the classic case of different representations for the same
thing, like using cartesian coordinates vs. polar / spherical
coordinates for vectors.  Generally, it would make sense to use the most
convenient representation for the particular piece of code you're
working with, and interconvert where necessary.


T

-- 
If Java had true garbage collection, most programs would delete themselves upon execution. -- Robert Sewell


More information about the Digitalmars-d mailing list