From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: swedebugia@riseup.net Newsgroups: gmane.lisp.guile.user Subject: Re: Guile equivalent to JS promises? Date: Mon, 10 Dec 2018 10:56:09 -0800 Message-ID: <8cd3563637e58b4ae92c554a40433c51@riseup.net> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1544468096 18868 195.159.176.226 (10 Dec 2018 18:54:56 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 10 Dec 2018 18:54:56 +0000 (UTC) Cc: Guile User To: "Thompson, David" Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Dec 10 19:54:51 2018 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gWQhf-0004oa-2q for guile-user@m.gmane.org; Mon, 10 Dec 2018 19:54:51 +0100 Original-Received: from localhost ([::1]:34341 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWQjl-0000b1-Lq for guile-user@m.gmane.org; Mon, 10 Dec 2018 13:57:01 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWQj1-0000Lq-V5 for guile-user@gnu.org; Mon, 10 Dec 2018 13:56:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gWQiy-0004af-F0 for guile-user@gnu.org; Mon, 10 Dec 2018 13:56:15 -0500 Original-Received: from mx1.riseup.net ([198.252.153.129]:43057) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gWQiy-0004Zz-4Y for guile-user@gnu.org; Mon, 10 Dec 2018 13:56:12 -0500 Original-Received: from piha.riseup.net (piha-pn.riseup.net [10.0.1.163]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.riseup.net (Postfix) with ESMTPS id C0B5A1A36DD; Mon, 10 Dec 2018 10:56:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1544468169; bh=x5ST8Ns0YG7Lt0bGYxe+/fQKCdAPGdlTmazkkqiRzwg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=gXX3TilkxT4Q4082OAhlx4m0DyNqHhowOHxXeX77osx/RsxuL5h0w5wv71NdUswNu zdH2B7H26WJgpsRcu5RyYQBSZ7mEN2jZf2WDnlVzRHl+bUbLZ86bH4nsFM8XnxCOhx lT8TkComGpbHcPw0W9eEK1SpvulHbMtsTQbeE1Ec= X-Riseup-User-ID: 94AEB06AF59F7A156E27E1E3C8B188BC31712798F1D3D8D537A46DE36DCACF34 Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) by piha.riseup.net with ESMTPSA id A1CC46A5F1; Mon, 10 Dec 2018 10:56:09 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 198.252.153.129 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:15042 Archived-At: 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