[swift-evolution] Pitch: Compound name `foo(:)` for nullary functions
Jacob Bandes-Storch
jtbandes at gmail.com
Wed Feb 22 14:27:51 CST 2017
Just to throw out some other options: foo(#) and foo(@).
(And you thought we'd gotten rid of # argument labels! đ)
On Wed, Feb 22, 2017 at 11:48 AM David Sweeris <davesweeris at mac.com> wrote:
>
> > On Feb 22, 2017, at 11:05 AM, Matthew Johnson <matthew at anandabits.com>
> wrote:
> >
> >
> >> On Feb 22, 2017, at 12:30 PM, David Sweeris <davesweeris at mac.com>
> wrote:
> >>
> >>
> >>> On Feb 22, 2017, at 7:48 AM, Matthew Johnson via swift-evolution <
> swift-evolution at swift.org> wrote:
> >>>
> >>> I like this idea. I think you made the right choice of syntax given
> the alternatives considered. To me `foo(_)` and `foo(:)` equally imply
> presence of an argument. The former looks like an anonymous (unnamed)
> argument and the latter includes the colon which only follows an argument.
> Between the two `foo(:)` is the better choice because it doesnât look like
> a pattern as has been pointed out.
> >>>
> >>> Iâm going to do a little brainstorming to try and come up with
> something that works and doesnât imply an argument at all but suspect Iâll
> come up empty handed.
> >>
> >> What about âfoo(Void)â? It might be fairly easily confused with
> âfoo(:Void)â, but in practice, how likely is it for someone to declare both
> `foo()` and `foo(_: Void)`?
> >
> > I almost threw out `foo(Void)` and `foo(Never)` as ideas. There is at
> least one problem with these. We will hopefully eventually get rid of the
> need to say `.self` in expressions like `Int.self`. If we are able to do
> that then `foo(Void)` and `foo(Never)` are syntactically valid function
> calls.
>
> Oh, good point! Hrmm⌠âfoo(#null)â/âfoo(#nullary)"? I canât imagine either
> of those would ever be valid function calls, and they get the point across
> (the later more than the former, but itâs more to type). I donât like that
> syntax for the name of âshortestâ version of the function isnât shorter
> than the syntax of the name for other versions of the function, though.
>
> - Dave Sweeris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170222/c8690d7e/attachment.html>
More information about the swift-evolution
mailing list