Uri class and parser
Mike van Dongen
dlang at mikevandongen.nl
Thu Nov 8 07:10:16 PST 2012
Been thinking about this for a while now, but I can't decide
which one I should choose.
Currently there is a class URI which has an static method
(parser) which returns an instance of URI on success. On failure
it will return null.
I agree with Jens Mueller on the fact that URI should be a struct
instead of a class. But then I won't be able to return null
anymore so I should throw an exception when an invalid URI has
been passed to the constructor.
I'm not sure if this is how problems are being handled in phobos.
Something entirely else is the CTFE compatibility of URI. At
first I though that because a new instance of URI can be created
as a const, it would be evaluated on compile time.
This is part of how I test CTFE at the moment:
const URI uri36 = URI.parse("http://dlang.org/");
assert(uri36.scheme == "http");
I tried changing 'const' to 'static' but that resulted in an
error.
(_adSort cannot be interpreted at compile time, because it has no
available source code)
Now I'm not sure anymore how to test if my code meets the CTFE
requirements.
I hope someone can shed some light on my problems and help me
make a decision.
More information about the Digitalmars-d
mailing list