Existential Operator / Null Propagation Operator

Andreas Rossberg rossberg at google.com
Thu Aug 20 10:35:52 UTC 2015

On 19 August 2015 at 16:21, Tingan Ho <tingan87 at gmail.com> wrote:

> Strange why do they need an operator for that? Probably to make it less
> error prone with access nil errors. But that could be fixed with static
> code analysis.

OT but: The whole point of optional values (as opposed to
null/nil/undefined inhabiting everything) is to make the boundaries of
optionality explicit, thereby avoiding Hoare's billion dollar mistake.

That said, "convenient" operators like ! already destroy half the benefit.
Plenty of experience from other languages like ML or Haskell shows that
they are almost always used incorrectly (read: over-optimistically). If a
language has to have such an operator, it should at least be very explicit
and as inconvenient as bearable.


On Wed, Aug 19, 2015 at 10:09 PM, Kevin Smith <zenparsing at gmail.com> wrote:
>> In TypeScript `?` means optional. But throw if the value is nil is the
>>> same same as non-nullable?
>> In Swift, the postfix "!" operator unwraps an optional value, throwing if
>> nil.
>> See
>> https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/OptionalChaining.html
> --
> Sincerely,
> Tingan Ho
> @tingan87 <https://twitter.com/tingan87>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150820/13e4b7ed/attachment.html>

More information about the es-discuss mailing list