Re: Guile equivalent to JS promises?
Hi On 2018-12-10 15:37, Thompson, David wrote: > Hello! > > On Sun, Dec 9, 2018 at 5:52 AM 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 Thanks for the insights. :) Guile is indeed pretty neat. Thanks for the link. I started reading some of wingos blog. Some of it still goes way over my head but i'm learning. -- Cheers Swedebugia
Re: Guile equivalent to JS promises?
Hello! On Sun, Dec 9, 2018 at 5:52 AM 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
Re: Guile equivalent to JS promises?
swedebu...@riseup.net writes: > 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? > > -- > Cheers > Swedebugia I don't know JS promises, but have you seen https://www.gnu.org/software/guile/manual/html_node/Delayed-Evaluation.html? Regards, Neil
Guile equivalent to JS promises?
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? -- Cheers Swedebugia