March 05, 2011 [phobos] isemail error handling | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | Return by value.
Andrei
On 3/5/11 8:55 AM, Jacob Carlborg wrote:
> Yes of course, it's already an enum. I was concerned about the size of the struct or is it small enough to return by value?
>
|
March 05, 2011 [phobos] isemail error handling | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | Provide another function that will take the reason code and turn it into a user friendly string.
Jacob Carlborg wrote:
> Yeah, I guess it's more of a "reason code" than error code. But it feels like going back to C, returning status codes and have to look them up in some kind of table.
>
>
|
March 05, 2011 [phobos] isemail error handling | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Saturday 05 March 2011 03:07:29 Jacob Carlborg wrote:
> The PHP version returns "true", "false" or a code indicating why the email address isn't valid. In addition to that it has an out parameter, an array, containing among other things the local and the domain part of the address. I was thinking that I either keep it like that, with an out parameter, or return a struct with the information.
>
> If I return a struct I was thinking it would contain the following fields:
>
> bool valid;
> string local;
> string domain;
> int statusCode/reasonCode;
That sounds like a good solution. You could even add the string function for the reason code that Walter suggested to the struct itself. But a struct like that isn't all that large anyway. Returning a struct which implicitly casts to bool sounds like a solid solution though.
- Jonathan M Davis
|
Copyright © 1999-2021 by the D Language Foundation