On 19 August 2015 at 16:21, Tingan Ho <[email protected]> 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.

/Andreas


On Wed, Aug 19, 2015 at 10:09 PM, Kevin Smith <[email protected]> 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
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to