[Issue 6843] Function to check whether std.conv.to will succeed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Oct 23 11:11:43 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6843



--- Comment #3 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-10-23 11:10:36 PDT ---
They're similar but not the same. Bug# 6840 is suggesting the creation of a
template which wraps whether std.conv.to succeeds by catching the exception.
This is highly inefficient and ends up creating a new type in the deal, which
is messier IMHO.

What I'm suggesting here is that a new function be created which doesn't risk a
ConvException being thrown at all, completely avoiding the huge inefficiency of
catching the thrown exception.

And if we were to do something like maybeTo, I'd be tempted to find a way to
generalize it beyond std.conv.to to encompass any function which returns a
value and could have thrown an exception (probably by taking the function as
aliased template argument) rather than making it specific to std.conv.to. But
that's so insanely inefficient, that I wouldn't be in hurry to add something
like that to Phobos.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list