Trailing-Closure Blog Post

This is largely a result of my early work on Swift, but there was never any pushback along the years as other folks joined on.

For my part, the original driving reason was to be able to implement "control flow like" structures in the standard library. If you go all the way back, you'll see that I was originally trying to implement if and other statements in the standard library, and this led to some wacky stuff (e.g. overloading juxtaposition) that was eventually abandoned.

Besides that, I was aware of Ruby, but the bigger issue was the Objective-C design pattern that encouraged blocks to be the last argument, and the goal to make that feel more natural and nicer.

That said, the actual closure syntax iterated a bunch, the first recorded entry in the changelog talks about it. we went through pipe syntax and other experiments as well.

-Chris

14 Likes