News for hackers. Stuff that matters.
Re:Kotlin 1.4 by agumonkey on Tuesday August 18, 2020 @08:37AM (#24197874)
is that modeled on ruby ?
Re:Kotlin 1.4 by vvillena on Tuesday August 18, 2020 @08:45AM (#24197942)
This is a very common idiom in Scala. Function definition is slightly different, but usage is the same.
Re:Kotlin 1.4 by agumonkey on Tuesday August 18, 2020 @09:13AM (#24198153)
Any example ? or an idiom name I can google ?
Re:Kotlin 1.4 by swsieber on Tuesday August 18, 2020 @09:49AM (#24198490)
Groovy also does it. I have no idea what the name is though: https://mrhaki.blogspot.com/2009/11/groovy-goodness-passing-...
Re:Kotlin 1.4 by matsemann on Tuesday August 18, 2020 @05:09PM (#24204373)
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.
Re:Kotlin 1.4 by matsemann on Wednesday August 19, 2020 @03:31AM (#24208042)
Re:Kotlin 1.4 by jayrhynas on Tuesday August 18, 2020 @03:11PM (#24202964)
Swift calls it trailing closure syntax
Re:Kotlin 1.4 by agumonkey on Tuesday August 18, 2020 @04:43PM (#24204106)
Ok so it's an explicit parameter, the function is just ~curried so you can just write it nicely.
Re:Kotlin 1.4 by pjmlp on Tuesday August 18, 2020 @10:41AM (#24199129)
Not at all, it is very common in ML languages, Smalltalk, and even Groovy already had it.
Re:Kotlin 1.4 by agumonkey on Tuesday August 18, 2020 @01:56PM (#24201887)
I never saw that idiom in any ml classes.. I'm honestly surprised
Re:Kotlin 1.4 by pjmlp on Wednesday August 19, 2020 @05:40AM (#24208688)
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.

Re:Kotlin 1.4 by untog on Tuesday August 18, 2020 @09:48AM (#24198478)
I don't know, but you can do the exact same thing in Swift.