Safe navigation operator

Brian Goetz brian.goetz at
Thu Jan 17 13:13:27 UTC 2019

> One reason why I would not consider this feature at this point is that it is useless if the type of the field being referenced is a primitive; in order to make this feature not do something silly at this point, we’d need nullable primitives types (`int?`).  C# went this way, and its a valid way, but it’s not a small tweak.  
> hmmm, actually primitives wouldn't be the problem , i imagine. It would be applied only to objects. But i get your point about the diferent scenarios that we would have to think about.

While the _dereference_ operator is only applied to objects, the _result_ may not be an object.  For example:

    class Foo {
        int i;

    Foo f = null;
    … f?.i …

What should f?.i evaluate to if f is null?  There are two realistic choices: disallow it (which would greatly reduce the value of the feature) or evaluate to some sort of “nullable int”.  If you can’t apply it all the way through the chain, you _still_ have to stop at the last one and do a null check — kind of undermining the benefit of the feature.  

> A last question: Is amber open to community help on development? I mean, i random guy like me could help on talk about and develop new features?

Help is always appreciated.  Realistically, the most effective place for new folks to get involved is in _testing_ of new features.  This also is a good way to familiarize yourself with the code base, process, and tooling.  

More information about the amber-dev mailing list