ponylang / rfcs

RFCs for changes to Pony
https://ponylang.io/
59 stars 48 forks source link

Support for context #99

Closed diegobernardes closed 7 years ago

diegobernardes commented 7 years ago

Lately a lot of my time has been on the Go programing language. Go has lots and lots of things that are very nice, one is the context package, it's based on this interface:

type Context interface {
        Deadline() (deadline time.Time, ok bool)
        Done() <-chan struct{}
        Err() error
        Value(key interface{}) interface{}
}

This can be used for anything, on web programming, every request has a context embedded, it can be used to cancel all the request chain on timeout or if the client disconnect. Can be used too to share values on request chain.

I'm new to Pony, don't know how this could be included on the language or if it should be included. Being on the stdlib, encourages others to use the same pattern and produces a unified way to control concurrency.

More about the context package on Go: https://blog.golang.org/context

Praetonus commented 7 years ago

I don't know Go very well so I could be missing something, but it looks like a Context is to Go what a Promise is to Pony. Both act as glue between units of concurrency (goroutines in Go, actors in Pony), but a Context is a synchronous concept while a Promise is an asynchronous one.

Pony being a fully asynchronous language, having a synchronous equivalent to Promises doesn't look really useful to me.

diegobernardes commented 7 years ago

Sorry, new to Pony, didn't know about Promise. Yes, gonna work the same way.

SeanTAllen commented 7 years ago

@diegobernardes quite alright. IRC and the mailing list are great places to get help exploring what is and isn't available in Pony. You can find links to both: https://www.ponylang.org/community/#getting-started

Hopefully, your Pony experience is a positive one.