hi! we’ve just published a blog post about a parti...
# feed
a
hi! we’ve just published a blog post about a particular style of programming in Kotlin, heavily influenced by functional programming ideas but still Kotlin-idiomatic. I hope you enjoy it! https://xebia.com/blog/the-suspend-receivers-style-in-kotlin/
🙌🏾 1
🙌 5
👍🏻 1
y
At a conceptual level, you can think of
Continuation<A>
as simply a function
(A) -> Unit
. This means the caller can change how the function "returns," but changing the continuation passed as parameter
k
.
I believe that's meant to say by changing the continuation not but changing the continuation
Not trying to nitpick or anything, it just confused me a bit while reading lol
a
oh, thanks for the catch 🙂
n
great article, thanks (although it is for advanced Kotlin users imho)
One more question: could someone please explain why continuations are needed at all to implement these features?
a
continuations are what lays below the
suspend
mechanism
the important part here is that continuations give you power about how the code they live in is executed
for example, you can decide that if you call a certain function, nothing else in the block ought to be executed
🙏 1
n
you can decide that if you call a certain function, nothing else in the block ought to be executed
Hmmm, this must be the key reason for using them. But cannot this mechanism also be implemented by using non-
suspend
functions and throwing-catching exceptions?
a
the key difference is that with exceptions you can decide to break execution at some point, but you cannot do things like “pause execution, do a bit on the side, then resume where it was before”, which is something you can do with continuations (because you decide at which point tou call
resume
)
👍🏻 1
🙏 1
n
you cannot do things like “pause execution, do a bit on the side, then resume where it was before”,
One last question: then how is it possible to have an
eagerEffect {}
as well in Arrow? Does it have some serious limitations compared to
effect {}
?