[swift-evolution] Discussion: Why is "nil" not "none"
Saagar Jha
saagarjha28 at gmail.com
Tue Jun 7 19:30:17 CDT 2016
That’s not quite what I meant. nil feels right to refer to an object-you
can say “Foo is nil”, but you can’t really say that “Foo is none”, since
while you can’t really use none as an adjective, as you can with nil. It’s
really about what flows right-none is the opposite of some, but nil isn’t.
On Tue, Jun 7, 2016 at 5:16 PM Brandon Knope <bknope at me.com> wrote:
> That's exactly the point I was going for.
>
> none makes more sense in this context than nil in my opinion
>
> Brandon
>
> On Jun 7, 2016, at 8:10 PM, Saagar Jha <saagarjha28 at gmail.com> wrote:
>
> Well, some is the opposite of none in that if I don’t have some, I have
> none. nil is just a carry-over from Objective-C.
>
> On Tue, Jun 7, 2016 at 5:07 PM Brandon Knope via swift-evolution <
> swift-evolution at swift.org> wrote:
>
>> I guess for me it comes down to this:
>>
>> *Why were some and none chosen for as the cases for Optional?*
>>
>> As an extension of that, why does nil then represent none instead of the
>> obvious none?
>>
>> There has to be a reason why it's not:
>>
>> enum Optional<T> {
>> case some(T)
>> case nil
>> }
>>
>> None seems a lot more expressive and consistent with Optional.
>>
>> I am comfortable and use to nil, but with swift being a new language, I
>> thought it was worth opening up a discussion about possibly changing
>> direction a little here.
>>
>> Thanks,
>> Brandon
>>
>> On Jun 7, 2016, at 7:57 PM, Jordan Rose <jordan_rose at apple.com> wrote:
>>
>> There are NilLiteralConvertible types other than Optional, but they’re
>> dwindling now that pointer nullability is represented by Optional. That
>> said, I’m not convinced renaming “nil” is worth it at this point.
>> Similarity with other languages is still a good thing.
>>
>> It’s true that we might not have picked nil if it hadn’t been for
>> Objective-C, but that doesn’t make it an invalid choice. There are lots of
>> things in Swift we might have done differently if it weren’t for
>> Objective-C and Cocoa.
>>
>> Jordan
>>
>>
>> On Jun 5, 2016, at 12:35, Brandon Knope via swift-evolution <
>> swift-evolution at swift.org> wrote:
>>
>>
>> Quick thought:
>>
>>
>> If optional has a .none case, wouldn't it be more consistent to rename
>> nil to none?
>>
>>
>> Also, would nil make it into Swift if not for other languages?
>>
>>
>> It also might make it somewhat clearer:
>>
>>
>> var someInt: Int? = none //looks less like a pointer and more like a
>> value of nothing
>>
>>
>> 1. It is more consistent with the optional enum
>>
>> 2. The intent is arguably clearer
>>
>> 3. nil makes it seem like it's a pointer
>>
>> 4. Would nil be included if not for prior languages? Would "none" have
>> been chosen as the keyword if nil wasn't prior art?
>>
>>
>> One disadvantage is how close it is to .none, but with how common
>> nil/none is used, some syntactic sugar might make it look nicer than always
>> having the stray .
>>
>>
>> On vacation from Orlando, poolside, with a quick thought,
>>
>> Brandon
>>
>> _______________________________________________
>>
>> swift-evolution mailing list
>>
>> swift-evolution at swift.org
>>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
> --
> -Saagar Jha
>
> --
-Saagar Jha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160608/380a8c74/attachment.html>
More information about the swift-evolution
mailing list