Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

is that modeled on ruby ?


This is a very common idiom in Scala. Function definition is slightly different, but usage is the same.


Any example ? or an idiom name I can google ?


Groovy also does it. I have no idea what the name is though: https://mrhaki.blogspot.com/2009/11/groovy-goodness-passing-...


Not sure about the exact name. But kotlin also has "function with receiver" that together with this makes it very easy to write almost a custom domain language on top of kotlin.



Swift calls it trailing closure syntax


Ok so it's an explicit parameter, the function is just ~curried so you can just write it nicely.


Not at all, it is very common in ML languages, Smalltalk, and even Groovy already had it.


I never saw that idiom in any ml classes.. I'm honestly surprised


It is a common idiom for dealing with deterministic resource management, and takes advantage that in ML all functions are single parameter actually.

So you can partially specialize, and then the lambda gets the already allocated/opened resource, thus acting as region/arena resource allocator.

And you can combine it with currying to apply the concept to multiple kind of parameters.


I don't know, but you can do the exact same thing in Swift.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: