[swift-evolution] Why doesn't Swift allow a variable and a function with the same name?

Xiaodi Wu xiaodi.wu at gmail.com
Mon Jan 30 22:14:25 CST 2017


Just left a comment on the bug; it's clear we need some sort of new syntax,
and I'd like to throw out `foo(:)` as a candidate, by analogy with `[:]`
being an empty dictionary.
On Mon, Jan 30, 2017 at 22:04 Jacob Bandes-Storch via swift-evolution <
swift-evolution at swift.org> wrote:

> You said "The ability to reference a function by only the first segment of
> its name is likewise legacy of the original model..." — how else could you
> refer to a nullary function? Even if labels were required for naming
> (>0)-ary functions, there's still ambiguity between a nullary function and
> a variable.
> On Mon, Jan 30, 2017 at 7:54 PM Joe Groff <jgroff at apple.com> wrote:
>
>
> > On Jan 30, 2017, at 7:34 PM, Jacob Bandes-Storch <jtbandes at gmail.com>
> wrote:
> >
> > Although there's no spelling for this...
> https://bugs.swift.org/browse/SR-3550
>
> IMO, the way to spell `foo` with no arguments is just `foo`. If we
> strictly required the labels for referring to n-ary functions, that would
> make it unambiguous…
>
> -Joe
>
> _______________________________________________
> 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/20170131/b7e00e46/attachment.html>


More information about the swift-evolution mailing list