From: Jean Privat Date: Thu, 18 Jul 2019 18:39:57 +0000 (-0400) Subject: Merge: Safe call operator X-Git-Url: http://nitlanguage.org Merge: Safe call operator A long time ago, there was a proposal to have a safe call operator in Nit #1274 `x?.foo` that executes the call if `x` is not null and returns null otherwise (instead of aborting). This was refused because at the time, the syntax `x?.foo` was considered weird and not POLA. Moreover, what was proposed was a more general version of the concept that could be used everywhere, not only as a receiver that made the semantic quite complex and even less POLA. Nowadays, most languages have adopted it https://en.wikipedia.org/wiki/Safe_navigation_operator so the syntax and behavior is not as weird as before. This operator is nice in the context of Nit with nullable types since if avoids to use chained `if x != null then x.foo` and plays nicely with the type system. Currently, only explicit dotted calls are handled; e.g. `x?.foo`, I'm not sure if something should be done with other call constructions like `x + y` or `x[y]`. Pull-Request: #2761 Reviewed-by: Lucas Bajolet Reviewed-by: Alexandre Terrasa --- 17ea05c8a942c42ed83c3206c5226e22c26eee8e