Hello! On Sun, Dec 9, 2018 at 5:52 AM <swedebu...@riseup.net> wrote: > > Hi > > I'm trying to understand JS promises. > > Are promises relevant in Guile? > > According to https://www.promisejs.org/ they seem to be a tool to > read/write JSON in a nonblocking way. > > Is this related to threading where the JS dev want multiple threads to > read stuff asynchroniusly at the same time?
So, promises are basically just callback functions + error handling + a way to compose them together in a chain. I don't know of any existing Guile library that implements this API, but it wouldn't take much code to make a Scheme equivalent. However, I am hesitant to recommend promises for writing asynchronous programs for a variety of reasons. [1] Fortunately, Guile is pretty neat and provides a low-level feature that allows for much nicer asynchronous programming models: delimited continuations. I won't go into much detail about them here (see call-with-prompt in the manual), but Andy Wingo's guile-fibers [2] project is a really neat asynchronous programming library built on top of delimited continuations. And here's my favorite guile-user post of all time in which Andy drops a 13 line coroutine implementation (this blew my mind many years ago): https://lists.gnu.org/archive/html/guile-user/2011-02/msg00031.html tl;dr - use a system based on delimited continuations or write your own! Hope this helps! - Dave [1] http://wingolog.org/archives/2016/10/12/an-incomplete-history-of-language-facilities-for-concurrency [2] https://github.com/wingo/fibers