Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
jayvanguard
on June 20, 2014
|
parent
|
context
|
favorite
| on:
Interesting Swift Features
Trailing closures turn out to be magic when creating APIs and mini-DSLs. That slight reduction of friction that unifies regular language syntax with user-defined functions is often the difference between a high usable extension and a kludge.
mikeash
on June 20, 2014
[–]
Do you happen to have any good examples? They look like a great feature but I'm less familiar with how they've already been used in other languages.
bronxbomber92
on June 20, 2014
|
parent
|
next
[–]
Scala is full of many libraries that take advantage of trailing closures. I think their standard library Future/Promise API is good example:
http://docs.scala-lang.org/overviews/core/futures.html
Edit: Another popular one is the ScalaTest unit testing framework:
http://www.scalatest.org
jayvanguard
on June 20, 2014
|
parent
|
prev
|
next
[–]
Take a look at one of the tutorials on writing a Ruby DSL. E.g.
http://rubylearning.com/blog/2010/11/30/how-do-i-build-dsls-...
chc
on June 20, 2014
|
parent
|
prev
[–]
I think Ruby is the major banner-carrier for this feature. It is actually more awkward in Ruby to have
non
-trailing closures.
Consider applying for YC's Spring batch! Applications are open till Feb 11.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: