> On May 14, 2017, at 11:44 PM, André Videla via swift-evolution
> <[email protected]> wrote:
>
>> Joe also referred to the following model in a thread about Typed Throws.
>>
>> () -> () == () throws Never -> ()
>> () throws -> () == () throws Error -> ()
> That makes sense! As a bottom type it would be perfectly fit for this.
>
>> On 15 May 2017, at 03:01, Robert Widmann <[email protected]> wrote:
>>
>> Though our type lattice doesn’t necessarily have a bottom in the way you’re
>> looking for, you can use Never-returning functions to inhabit a combinator
>> that will do this for you.
> Very useful.
> What do you think of [] as [Never], or nil as Optional<Never>. Can the
> current inference and subtyping rules deal with that?
If you mean does this currently compile:
let f:Optional<Never> = nil
let g:[Never] = []
then yes. However, “nil” and “[]” in the above are literals, not types or type
instances. They only are used to initialize an instance of a type that is
ExpressibleByNilLiteral / ExpressibleByArrayLiteral.
If Never becomes a bottom type, a [Never] or Never? hypothetically could be
passed into any function which accepts an array or optional of any type because
of covariance and value types, but would always be empty/none version of that
type. I can’t think of a practical reason to do this, although I admit I’ve
never used a language with a bottom type.
-DW
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution