Is there a strong reason for Nullable's alias get this?

Nick Treleaven nick at geany.org
Wed Apr 18 10:01:17 UTC 2018


On Wednesday, 18 April 2018 at 08:24:14 UTC, FeepingCreature 
wrote:
> If nobody objects, I'll make a PR to deprecate it.

+1. Nullable has received some improvements lately, it would be 
great if `get` was no longer implicit. For new code, it is 
trivial to write `.get` to convert to the original type. For old 
code, deprecation is a good solution. (Permanent deprecation can 
solve the problem of breaking code in the longer term).

There is an argument for making `get` *require* a fallback value 
rather than a default `.init` argument, to make the conversion 
completely explicit, but this is perhaps a change too far 
considering how lax we currently are. A third way would be to 
require a fallback argument only when the original type doesn't 
have a good invalid value like null. At least null dereference, 
if triggered, will be detected immediately upon execution. An 
unexpected zero-value might go undetected for a long time.


More information about the Digitalmars-d mailing list