[swift-evolution] [Draft] Abolish IUO type
James Campbell
james at supmenow.com
Fri Mar 18 06:20:19 CDT 2016
One thing I've had bit me is the lack of some sort of confirmation, see
this example.
I have a objective-c method in a library like so:
- (void)observe:(CallbackBlock)block;
The CallbackBlock is a type def-ed block like so:
typedef void (^CallbackBlock)(FDataSnapshot *snapshot);
The parameter in the block gets converted into a IUO, I ended up releasing
an app that crashed due to that IUO being nil.
The code that crashed was something like this
object.observe {
$0.doSomething()
}
There is no way to tell that the $0 was a IUO. The compiler didn't force me
to confirm in it in some way using a ! and unless I remembered to check the
header I would have a crash.
How would this work under your proposal ?
*___________________________________*
*James⎥Head Of CEO*
*james at supmenow.com <james at supmenow.com>⎥supmenow.com <http://supmenow.com>*
*Sup*
*Runway East *
*10 Finsbury Square*
*London*
* EC2A 1AF *
On Fri, Mar 18, 2016 at 6:53 AM, Brent Royal-Gordon via swift-evolution <
swift-evolution at swift.org> wrote:
> > (Come to think of it, is there a cost to converting between `T?` and
> `T!`, or do they get optimized into the same thing?)
>
> I can't imagine there would be. @autounwrapped (or whatever) is a purely
> compile-time thing which tells the compiler to automatically insert a `!`
> operator if it will make the expression typecheck. Other than that
> compile-time behavior, `!` is an exact synonym for `?`.
>
> --
> Brent Royal-Gordon
> Architechies
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160318/462ddd99/attachment.html>
More information about the swift-evolution
mailing list