based on a post of mine in "getting-started" <http...
# language-proposals
m
based on a post of mine in "getting-started" https://kotlinlang.slack.com/archives/C0B8MA7FA/p1659464960124589 currently its possible to define an inner function within builders. If you have recursive logic, this is nice to work with. e.g. for a personal project I can easily do this:
Copy code
fun holeFiller(spaces: Int, totalSum: Int): List<List<Int>> = buildList {
    fun fill(sumToGo: Int, list: List<Int> = emptyList()) {
        when (list.size) {
            spaces - 1 -> add(list + sumToGo)
            else -> for (i in 0..sumToGo) {
                fill(sumToGo - i, list + i)
            }
        }
    }
    fill(totalSum)
}
However, if I want to have this with a sequence, the function "fill" needs to be specified as
Copy code
suspend fun SequenceScope<List<Int>>.fill
It would be nice if an inner function of a sequence implicitly works like this
y
How will this work when specifying function references? There are use cases where someone wants to define an inner function that is explicitly not
suspend
or explicitly isn't within a
Sequence
m
those inner functions HAVE to be called within the scope of the sequence right? That means they need to be suspended? Or can you give me an example where that isn't the case?