unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Guile equivalent to JS promises?
@ 2018-12-09 10:52 swedebugia
  2018-12-10 13:49 ` Neil Jerram
  2018-12-10 14:37 ` Thompson, David
  0 siblings, 2 replies; 4+ messages in thread
From: swedebugia @ 2018-12-09 10:52 UTC (permalink / raw)
  To: Guile User

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Guile equivalent to JS promises?
  2018-12-09 10:52 Guile equivalent to JS promises? swedebugia
@ 2018-12-10 13:49 ` Neil Jerram
  2018-12-10 14:37 ` Thompson, David
  1 sibling, 0 replies; 4+ messages in thread
From: Neil Jerram @ 2018-12-10 13:49 UTC (permalink / raw)
  To: swedebugia, Guile User

swedebugia@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




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Guile equivalent to JS promises?
  2018-12-09 10:52 Guile equivalent to JS promises? swedebugia
  2018-12-10 13:49 ` Neil Jerram
@ 2018-12-10 14:37 ` Thompson, David
  2018-12-10 18:56   ` swedebugia
  1 sibling, 1 reply; 4+ messages in thread
From: Thompson, David @ 2018-12-10 14:37 UTC (permalink / raw)
  To: swedebugia; +Cc: Guile User

Hello!

On Sun, Dec 9, 2018 at 5:52 AM <swedebugia@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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Guile equivalent to JS promises?
  2018-12-10 14:37 ` Thompson, David
@ 2018-12-10 18:56   ` swedebugia
  0 siblings, 0 replies; 4+ messages in thread
From: swedebugia @ 2018-12-10 18:56 UTC (permalink / raw)
  To: Thompson, David; +Cc: Guile User

Hi

On 2018-12-10 15:37, Thompson, David wrote:
> Hello!
> 
> On Sun, Dec 9, 2018 at 5:52 AM <swedebugia@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

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-10 18:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-09 10:52 Guile equivalent to JS promises? swedebugia
2018-12-10 13:49 ` Neil Jerram
2018-12-10 14:37 ` Thompson, David
2018-12-10 18:56   ` swedebugia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).