[swift-evolution] [Pitch] Nil struct

Anton Zhilin antonyzhilin at gmail.com
Tue Nov 8 15:40:42 CST 2016

2016-11-09 0:12 GMT+03:00 Adrian Zubarev <adrian.zubarev at devandartist.com>:

Could you elaborate an implementation for one of these functions:
func == <T>(left: T?, right: Nil) {
    switch left {
        case .some(_): return false
        case .none: return true

The implementation is basically the same as of now, except that instead of
Nil, there is _OptionalNilComparisonType.

Main use case of Nil would essentially be partial specialization of
See example with optional comparison: there exists a generic version that
takes a proper ExpressibleByNilLiteral (in this case Optional<T>), but we
can apply simpler logic in case we see nil.

Frankly speaking, I’m not sure myself this feature would find any use
except for the mentioned optional comparison operators.
So I will probably stop pushing this forward.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161109/0a3c0fcd/attachment.html>

More information about the swift-evolution mailing list