[swift-evolution] Disambiguate Return Type With Void
Andrew Bennett
cacoyi at gmail.com
Tue Apr 26 05:56:12 CDT 2016
Hey,
I thought I would post another message to this thread because I think it
was missed when I first sent it (I made the mistake of sending it at 1am
San Francisco time, I'm in Australia).
I appreciate any feedback :)
Thanks,
Andrew
On Mon, Mar 28, 2016 at 7:21 PM, Andrew Bennett <cacoyi at gmail.com> wrote:
> Swift can resolve functions based on the return type. However, when the
> result is unused a single function often can't be resolved without
> explicitly specifying the type.
>
> func example() { ... }
> func example() -> Int { ... }
>
> example() as Void
> example() as Int
>
> This proposal disambiguates some cases:
>
> - Preferring functions with a *Void* return type when the result *is*
> discarded.
> - Preferring functions with a *non-Void* type when the result *is not*
> discarded.
>
> These example will be unambiguous:
>
> example() // will prefer a `Void` function
> let x = example() // will prefer a non-`Void` function
>
> You can read the full latest version of the proposal here:
>
>
> https://github.com/therealbnut/swift-evolution/blob/andrew-disambiguate-return-type/proposals/0000-disambiguate-return-type.md
>
> This is the original version
> <https://github.com/therealbnut/swift-evolution/blob/59d0f0b9bdabcfd675f36824232a8efa4a5f9152/proposals/0000-disambiguate-return-type.md> of
> the proposal.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160426/893fdace/attachment.html>
More information about the swift-evolution
mailing list