-
Notifications
You must be signed in to change notification settings - Fork 523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suspend terminology #152
Comments
Capturing an effect goes hand in hand with suspending a computation. You can't capture the effect without it. The
In my mind as a non-native English speaker, suspend is a synonym for pause. For it to be used for say Aka from a semantics point of view, this doesn't make much sense: Future.suspend {
Future(1 + 1)
} I don't know how Kotlin's coroutines work, but if they are anything like Scala's But most importantly, we cannot change Maybe even more important is usage of Task.suspend, the Scalaz 7 TL;DR — consistency with Kotlin or Haskell is actually far less important than consistency with the rest of the Scala ecosystem and everybody has used Btw
In general when talking of referential transparency, we ignore memory allocation, however with eager evaluation and without having tail calls optimized by the runtime, in many cases we need to suspend execution in order to preserve stack safety. See my recent PR from Cats for example: typelevel/cats#2185
So in this particular instance |
Btw @backuitist, Kotlin's Arrow is also doing IO.suspend as well. They got it from us actually. Didn't seem to upset @pakoito 🙂 |
There's been a minor embuggerance by the Kotlin std library in that |
Ah, so @backuitist was right for mentioning it for Kotlin. We've been using |
Yes, my only concern is that in other places |
There's a longer discussion about this in the fs2 ticket linked above. In particular I also don't think |
@alexandru val io = IO.suspend {
println("hello")
} Then per this definition, you'd expect io.resume() // prints hello
io.resume() // already resumed
IMO its prime responsibility is capturing an effect. Providing stack safety is a nice, orthogonal, by-product and must be mentioned in the doc, but I believe it's better to have a term that describes accurately what a function is primarily designed for than something fuzzy that conflates both meanings.
That's a good point and I understand that it isn't very practical to rename all these things, still raising this issue is perhaps useful for future readers to have an idea of the origins of this terminology. |
@backuitist got this email with your message, but now I'm not seeing it anymore, either GitHub is playing tricks or you deleted it 🙂
I understand your reticence for However a rename won't happen because:
At this point trying to rename Mind you, Scala does not have the greatest track record in regards to API breakage. And it kind of sucks, no matter what we tell ourselves. Personally I'm a fan of Rich Hickey's philosophy, that he presents in his Spec-ulation presentation. In it he claims that API breakage should never happen without a namespace change (e.g. We can't do that, I would be on board with it but we don't have buy-in from the rest of the community. But it should go without saying that renaming
N.B. allocating stack space is a side effect. If it wouldn't be, then pure, eager programs wouldn't crash. You can encounter this problem sometimes in Haskell too. We just choose to ignore it for practical purposes 😉 Also, technically, it has no such thing as a "prime responsibility". Yes, it's about suspending side effects, however its responsibility is to uphold the laws defined by SyncLaws. So actually its only responsibilities at the moment are these:
This is another way of saying that while some people, like us, care about names, in terms of what the thing actually does, only the described laws are important.
I think your real issue here is with "blocking", with which I actually agree 🙂 But changing |
I indeed deleted it, but you were too quick! :) I thought that last comment didn't add much value to the debate, as it's pretty clear that things won't change. At least my last point regarding future readers holds! |
@backuitist we have a documentation website now and we probably should add explanations on this terminology somewhere in there. Can we close this issue for now? I like clean issue trackers 🙂 |
Sure. Thanks for the documentation!
…On Fri, Mar 23, 2018, 07:21 Alexandru Nedelcu ***@***.***> wrote:
@backuitist <https://github.com/backuitist> we have a documentation
website now and we probably should add explanations on this terminology
somewhere in there.
Can we close this issue for now? I like clean issue trackers 🙂
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#152 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA-GwTqVws5qBpOqk4SvrzedkbBOVmcPks5thJSGgaJpZM4Srxq5>
.
|
Cats-effect uses
suspend
to describe the action of capturing an effect. I believe thatsuspend
is generally understood to mean something else: suspending a computation, that is, to return the control immediately.Here are a few occurrences that I found:
In addition, there exists a synonymous to suspend,
capture
as seen in #78In my opinion,
capture
does a better job at describing whatIO
does assuspend
suggests that "unsuspension" (i.e evaluating your effect) isn't repeatable. This is of course highly debatable.Furthermore, the use of
suspend
for side-effects makes it unavailable for other uses, such as a "semantically blocking" operation: typelevel/fs2#1097 (comment)The text was updated successfully, but these errors were encountered: