Project Elvis
Dmitry Olshansky
dmitry.olsh at gmail.com
Mon Nov 6 19:40:36 UTC 2017
On Monday, 6 November 2017 at 19:13:59 UTC, Adam Wilson wrote:
> On 10/28/17 04:38, Andrei Alexandrescu wrote:
>> Walter and I decided to kick-off project Elvis for adding the
>> homonym
>> operator to D.
>>
>> Razvan Nitu has already done a good part of the work:
>>
>> https://github.com/dlang/dmd/pull/7242
>> https://github.com/dlang/dlang.org/pull/1917
>> https://github.com/dlang/dlang.org/pull/1918
>
> Some years later the C# team introduces the Null-Conditional
> operator: ?. which allows you to write: obj1?.obj2?.prop3 ??
> constant.
>
> NOW people start using Null Coalescing all over the place.
>
So C# embraced the Null. Everything is nullable and you are
expected to ?. proof it if you don’t know in advance.
In contrast other languages (e.g. Scala) decided to discourage
the use of null in favor of algebraic type Option!T and even
remove the null all together.
> I am all for the Elvis operator, however I have two
> reservations about it.
To me the biggest reservation is “embracing the null” that this
entails.
In other words since we dedicate a feature to support nulls that
indicates null return is an endorsed aproach to e.g. model APIs
and libraries that deal with optional values.
I’d argue this NOT what we want. Nullability is best captured in
the typesystem even if in the form of Nullable!T.
More information about the Digitalmars-d
mailing list