On Thursday, 3 January 2013 at 21:51:14 UTC, H. S. Teoh wrote:
On Thu, Jan 03, 2013 at 08:40:47PM +0100, monarch_dodra wrote:
[...]
Or, you know... I could just implement both at the same time. It's not like there's an *urgency* for the ascii version or anything. I
think I'll just do that.

So... do we agree on
ascii: int - not found => -1
uni: double - not found => nan
[...]

LGTM. :)

I did think of what might happen if somebody wrote an int cast for
std.uni.numericValue
[SNIP]
writeln("Sloppy code caught the problem correctly!");

... alsmost! 1e12 will have a negative value when cast to int. To be 100% correct in regards to converting, the end user would have to use long.

But that'd be a *really exceptional* case behavior...

Even with long, the only problem with the code is that the user would not know the difference between exact integral, and inexact integral. Well, that's what the user gets for being sloppy I guess.

In any case, I think we'd have to provide an example section with a "recommended" way for casting to integral.

Reply via email to