Type to represent URIs?

Atila Neves atila.neves at gmail.com
Tue Jan 29 11:38:06 UTC 2019


On Monday, 28 January 2019 at 17:53:17 UTC, Victor Porton wrote:
> Which type should I use to represent (absolute) URIs (or URLs)?
>
> Is it OK to use `string` for this, or is there a better option?
>
> I could also use URI class from my library:
> https://github.com/vporton/redland-bindings/blob/dlang/dlang/source/rdf/raptor/uri.d
> https://github.com/vporton/redland-bindings/blob/dlang/dlang/source/rdf/redland/uri.d
>
> but as you see in this library there are two choices for URI 
> class and it's unclear which of the two I would use.

It depends.

If you have a function such as `void connect(string uri)` with 
only one parameter, I'd say a string is sufficient. If, however, 
it's `void fun(string uri, string config, string somethingElse)`, 
then use a URI type instead.


More information about the Digitalmars-d mailing list