On Sun, 03 Apr 2011 09:49:44 -0400, Andrei Alexandrescu <[email protected]> wrote:

On 4/3/11 6:38 AM, Jacob Carlborg wrote:
On 2011-04-02 23:33, Jonathan M Davis wrote:
On 2011-04-02 09:26, Jacob Carlborg wrote:
On 2011-04-01 11:01, Jonathan M Davis wrote:
On 2011-03-29 14:06, Jacob Carlborg wrote:
I've made a few minor changes:

* Renamed EmailStatusCode.Off -> None and On -> Any
* Added and clarified the documentation for EmailStatusCode.Any and
None
* Updated the documentation

Github: https://github.com/jacob-carlborg/phobos/tree/isemail
Docs: http://dl.dropbox.com/u/18386187/isemail.html

Shouldn't isEmail have a template constraint which verifies that the
e-mail variable is a valid string type? Also, it would probably be
better to use Char instead of T for the type. It's clearer that way. I
believe that that's what std.string does.

That's a good idea.

I'd say that pretty much every template should have a template
constraint on
it. I'm not sure that I've ever seen a template which was flexible
enough that
it would compile with anything you gave it, and if there's an argument
that
you can give it which won't compile with it, it should fail the template
constraints, otherwise the error messags are much harder to understand
and
track down.

I've added a static assert with a custom error message. I think static
asserts can give better error messages than template constraints.

Please use a template constraint. This is the right thing to do and we use it throughout Phobos.

Thanks,

Andrei

Also, static assert doesn't compose with is(typeof(...)) and __traits(compiles,...). (It stops the compiler if it's every evaluated) I'd recommend simply putting a string on an empty line over static assert:

static assert(...,"My error message");

static if(...) "My error message";

Reply via email to