[swift-evolution] Closure Syntax
Paul Cantrell
cantrell at pobox.com
Fri Jan 1 16:29:39 CST 2016
> On Jan 1, 2016, at 4:21 PM, Ethan Diamond via swift-evolution <swift-evolution at swift.org> wrote:
>
> FWIW I don't think the backlash to the use of ^ with Obj-C blocks was because of the carat itself, but because of the inconsistency of the syntax in different contexts. Sometimes the return type was after the ^, sometimes before. Sometimes you had to use (^). Sometimes the carat had the name of the block with it ^functionName. None of it fit in with the [object methodName] syntax of the language itself.
I’ll drop in a straight-up objection to the carat. The infix arrow syntax is perfectly clear, and in mathematical contexts has proved its readability since long before there were programming languages. Contra the proposal, there’s nothing wrong with this:
func makeIncrementer(forIncrement amount: Int) -> () -> Int
The carat, on the other hand, is noise. Only habituation to Obj-C blocks makes it seem like anything else.
I _do_ agree that the { foo, bar in … } syntax is clumsy, both graphically and grammatically. Definitely not my favorite part of Swift. I don’t find the carat a compelling fix, however.
Cheers,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160101/58c84d72/attachment.html>
More information about the swift-evolution
mailing list