[swift-evolution] [Proposal draft #2] Naming Functions with Argument Labels

Douglas Gregor dgregor at apple.com
Mon Jan 11 13:41:11 CST 2016

> On Jan 11, 2016, at 11:38 AM, Tino Heth <2th at gmx.de> wrote:
> I haven't had issues with ambiguous function names, but it just feels odd that there is no elegant way to solve those problems, so I agree that something should be done here.
> Speaking of the details, "(" always is an indication to me that there is a function to be called (not only referenced). Are there any special reasons for the parenthesis in this context?

That’s how we write Swift function names: basename(arglabel1:arglabel2:…arglabelN:).

> Wouldn't parsing be easier when we just leave out "(", ")" and "_”?

Parsing is easy either way.

> let fn1 = someView.insertSubview:aboveSubview:
> imho looks better.

Sometimes the first argument has a label, so just dropping it doesn’t actually work. It would have to be

	let fn1 = someView.insertSubview:_:aboveSubview:


	let fn1 = someView.insertSubview::aboveSubview:

which looks almost like the Objective-C selector, but isn’t. And it doesn’t match the way these methods are called.

	- Doug

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160111/e5f9eb46/attachment.html>

More information about the swift-evolution mailing list