[Issue 17896] Alternate version of std.conv.to which returns Nullable
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Oct 12 04:36:02 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=17896
--- Comment #2 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
(In reply to Steven Schveighoffer from comment #1)
> Can't we just hook with:
>
> to!(Nullable!int)
>
> ?
Maybe. It's not something I thought of. However, it _is_ possible right now to
have opCast return a Nullable!int for a user-defined type, in which case,
making to!(Nullable!int) special probably would not play well with that. Also,
I'd expect something like to!(Nullable!int)(42) to be essentially equivalent to
nullable(42), which I guess that it still ultimately would be, but you do start
to run the risk of having problems with any conversions right now that would
use Nullable and work.
It might actually ultimately work quite well, but it does seem to me like it
would be clearer and less risky to create a new function than to try and
special-case to - especially with how complicated it already is. It wouldn't be
hard for a corner case to cause problems that just wouldn't exist with a
separate function.
--
More information about the Digitalmars-d-bugs
mailing list