Re: [swift-evolution] [Proposal draft] Bridge Optional As Its Payload Or NSNull

2016-08-29 Thread Joe Groff via swift-evolution
> On Aug 25, 2016, at 9:34 AM, Douglas Gregor wrote: > I’d thought we were going to get some warnings when putting an optional into > an Any that would end up going into Objective-C, but I don’t see the warning: > maybe Joe can weigh in as to why we didn’t do that. Warning

Re: [swift-evolution] [Proposal draft] Bridge Optional As Its Payload Or NSNull

2016-08-26 Thread David Hart via swift-evolution
For what it’s worth, I’m very much behind this proposal. +1 > On 24 Aug 2016, at 00:36, Douglas Gregor via swift-evolution > wrote: > > Introduction > > Optionals can be used as values of the type Any, but only bridge as opaque > objects in Objective-C. We should

Re: [swift-evolution] [Proposal draft] Bridge Optional As Its Payload Or NSNull

2016-08-25 Thread Douglas Gregor via swift-evolution
> On Aug 24, 2016, at 6:27 PM, Greg Parker wrote: > > >> On Aug 23, 2016, at 3:36 PM, Douglas Gregor via swift-evolution >> > wrote: >> >> Proposed solution >> >> When an Optional value is bridged to an

Re: [swift-evolution] [Proposal draft] Bridge Optional As Its Payload Or NSNull

2016-08-24 Thread Charles Srstka via swift-evolution
> On Aug 24, 2016, at 10:40 PM, jaden.gel...@gmail.com wrote: > > Why is exposing an Optional as an opaque box less error prone than an NSNull? > That doesn't seem obviously true to me. Firstly, to answer your question: It is less error-prone because the error is more obvious. If an

Re: [swift-evolution] [Proposal draft] Bridge Optional As Its Payload Or NSNull

2016-08-24 Thread Omer Iqbal via swift-evolution
> The problem is that NSNull is in fact rare in Cocoa. I couldn't agree more. I think this proposal is quite dangerous for (often legacy) Objective C codebases where checking for NSNull is not common practice. Since Optionals are not a construct in Objective C, I don't see any reason for why

Re: [swift-evolution] [Proposal draft] Bridge Optional As Its Payload Or NSNull

2016-08-24 Thread Charlie Monroe via swift-evolution
> On Aug 25, 2016, at 5:00 AM, Charles Srstka via swift-evolution > wrote: > >> On Aug 24, 2016, at 8:27 PM, Greg Parker via swift-evolution >> > wrote: >> >>> On Aug 23, 2016, at 3:36 PM, Douglas Gregor

Re: [swift-evolution] [Proposal draft] Bridge Optional As Its Payload Or NSNull

2016-08-24 Thread Jaden Geller via swift-evolution
Why is exposing an Optional as an opaque box less error prone than an NSNull? That doesn't seem obviously true to me. > On Aug 24, 2016, at 8:00 PM, Charles Srstka via swift-evolution > wrote: > >>> On Aug 24, 2016, at 8:27 PM, Greg Parker via swift-evolution >>>

Re: [swift-evolution] [Proposal draft] Bridge Optional As Its Payload Or NSNull

2016-08-24 Thread Charles Srstka via swift-evolution
> On Aug 24, 2016, at 8:27 PM, Greg Parker via swift-evolution > wrote: > >> On Aug 23, 2016, at 3:36 PM, Douglas Gregor via swift-evolution >> > wrote: >> >> Proposed solution >> >> When an Optional

Re: [swift-evolution] [Proposal draft] Bridge Optional As Its Payload Or NSNull

2016-08-24 Thread Greg Parker via swift-evolution
> On Aug 23, 2016, at 3:36 PM, Douglas Gregor via swift-evolution > wrote: > > Proposed solution > > When an Optional value is bridged to an Objective-C object, if it contains > some value, that value should be bridged; otherwise, NSNull or another > sentinel

Re: [swift-evolution] [Proposal draft] Bridge Optional As Its Payload Or NSNull

2016-08-24 Thread Jaden Geller via swift-evolution
I'd imagine an implementation something like this (but, in the bridging logic, not as a top level function…): func dynamicCast(_ array: [Any]) -> [T?] { var _type: CollectionCastType? func assertType(_ checkType: CollectionCastType) { guard let type = _type else {

Re: [swift-evolution] [Proposal draft] Bridge Optional As Its Payload Or NSNull

2016-08-24 Thread Jaden Geller via swift-evolution
First of all, I'm really happy with this proposal so far. I really appreciate the work that's been done to improve Swift and Objective-C interoperability. Now, question: Does this proposal also improve bridging from Objective-C to Swift or only the other direction? For example, let's say an

Re: [swift-evolution] [Proposal draft] Bridge Optional As Its Payload Or NSNull

2016-08-24 Thread Douglas Gregor via swift-evolution
> On Aug 24, 2016, at 4:16 AM, David Rönnqvist > wrote: > > I have some problems understanding the scope of this proposal. More > specifically if it’s limited to arrays and dictionaries or if it’s broader > than that, and if it’s limited to objects that originate

Re: [swift-evolution] [Proposal draft] Bridge Optional As Its Payload Or NSNull

2016-08-24 Thread David Rönnqvist via swift-evolution
I have some problems understanding the scope of this proposal. More specifically if it’s limited to arrays and dictionaries or if it’s broader than that, and if it’s limited to objects that originate in Swift or if the same applies for objects that originate in Objective-C code. For me, it

[swift-evolution] [Proposal draft] Bridge Optional As Its Payload Or NSNull

2016-08-23 Thread Douglas Gregor via swift-evolution
Introduction Optionals can be used as values of the type Any, but only bridge as opaque objects in Objective-C. We should bridge Optionals with some value by bridging the wrapped value, and bridge nils to the NSNull singleton. Swift-evolution thread: TBD