[swift-evolution] Referencing zero-parameter functions

Xiaodi Wu xiaodi.wu at gmail.com
Thu May 5 13:39:57 CDT 2016


Can I offer a more verbose alternative? How's `foo() -> _` for referring to
a zero-parameter function? It's clearly not a function call, and it says
you want to match regardless of what the return value is...

On Thu, May 5, 2016 at 1:06 PM, Alex Hoppen via swift-evolution <
swift-evolution at swift.org> wrote:

>
> > On 05 May 2016, at 19:38, Joe Groff via swift-evolution <
> swift-evolution at swift.org> wrote:
> >
> >
> >> On May 5, 2016, at 10:16 AM, Jordan Rose via swift-evolution <
> swift-evolution at swift.org> wrote:
> >>
> >>
> >>> On May 5, 2016, at 10:03, Chris Lattner via swift-evolution <
> swift-evolution at swift.org> wrote:
> >>>
> >>> On May 5, 2016, at 8:59 AM, Alex Hoppen via swift-evolution <
> swift-evolution at swift.org> wrote:
> >>>> Say you have the function `foo() -> Int`. Then `foo()` calls `foo`
> and returns its return value of type `Int` – not a reference to the
> function of type `Void -> Int`.
> >>>
> >>> Right.
> >>>
> >>> That said, what is wrong with just “foo”?
> >>
> >> As pointed out in the original post, that can refer to both ‘foo()’ and
> ‘foo(bar:)’ today.
> >
> > We could change that, so that to refer to `foo(bar:)` you must use the
> full compound name.
> >
> > -Joe
>
> That would be my second favourite option if there is no support for
> `foo(_)`, which there doesn’t seem to be. If there is support for letting
> `foo` refer to the zero-parameter function, I will change the proposal.
>
> – Alex
> _______________________________________________
> 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/20160505/e85d561f/attachment.html>


More information about the swift-evolution mailing list