From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Vincent Bernat Newsgroups: gmane.lisp.guile.user Subject: guile and coroutines controlled from C Date: Sat, 28 Jul 2012 19:29:26 +0200 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1343496581 702 80.91.229.3 (28 Jul 2012 17:29:41 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 28 Jul 2012 17:29:41 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sat Jul 28 19:29:41 2012 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SvApd-0006kg-TQ for guile-user@m.gmane.org; Sat, 28 Jul 2012 19:29:38 +0200 Original-Received: from localhost ([::1]:51250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SvApc-000366-Uj for guile-user@m.gmane.org; Sat, 28 Jul 2012 13:29:36 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:44845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SvApY-000360-Ot for guile-user@gnu.org; Sat, 28 Jul 2012 13:29:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SvApX-0001Hp-Iw for guile-user@gnu.org; Sat, 28 Jul 2012 13:29:32 -0400 Original-Received: from bart.luffy.cx ([78.47.78.131]:60491) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SvApX-0001HX-96 for guile-user@gnu.org; Sat, 28 Jul 2012 13:29:31 -0400 Original-Received: from bart.luffy.cx (localhost [127.0.0.1]) by bart.luffy.cx (Postfix) with ESMTP id 9958A141B1 for ; Sat, 28 Jul 2012 19:29:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha1; c=simple; d=luffy.cx; h=from:to:subject :date:message-id:mime-version:content-type; s=postfix; bh=2WHEiX r9WPvjiHJ0QzGyeDXGP0A=; b=fM58BX/3phenyq5ORdHkdjbCJwoUnVeUveSMea pNswSSSHgtP6/2nfoMxFO7cpzaPYBoZj+nOTPBBRp+rdMGElS2QQXrmQI6yqjfnY S0irjbr8Jr/3iMDKgWGM5TvVBNnplKF9xkikayoYwkhh2iADlTyO8xzc8C4w44Vf IY8pc= DomainKey-Signature: a=rsa-sha1; c=simple; d=luffy.cx; h=from:to:subject :date:message-id:mime-version:content-type; q=dns; s=postfix; b= IJAlygJrSlocc8/d+PKjpsWM1DCmUn6V86VV6DRzBVoV9ZOTVPfGUYLutO24W8rP fuJUwln5LFxbubomYGRGDwBrzcgXsEnGlF6qNNfMaCcSSzlSCfA9xcjQvPQe0I5y WD+WNlrKB+YDshuISoFY+TVYMVhPLqfOdCfnoNcaeos= Original-Received: from neo.luffy.cx (unknown [IPv6:2a01:e35:8b01:4710:218:f3ff:fe03:4e06]) by bart.luffy.cx (Postfix) with ESMTPS id 62C5714110 for ; Sat, 28 Jul 2012 19:29:29 +0200 (CEST) Original-Received: by neo.luffy.cx (Postfix, from userid 500) id 2A842FB; Sat, 28 Jul 2012 19:29:27 +0200 (CEST) User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 78.47.78.131 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 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-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:9536 Archived-At: Hi! I would like to add Guile scripting to an actual program to allow a user to write simple network-related scenarios. Those scenarios will be run in parallel on several entities. The application is event-driven and I want to hide this fact to the user. She should be able to write a scenario in a simple blocking style: #v+ (let ((v1 (do-something-blocking "arg1" "arg2")) (v2 (do-something-blocking "arg3" "arg4"))) (when (< (+ v1 v2) 10) (...))) #v- `do-something-blocking` is a registered function written in C. I want to be able to pause the execution inside this function and then resume it later (when I my program got the data wanted by the user). In the meantime, another "cooperative thread" may be executed. In Lua, this is something that can be done with coroutines which can be yield and resumed from C. In Guile, there are continuations but I have hard time to understand how this should work from C. What would be the equivalent of this in Guile? http://kristianrumberg.wordpress.com/2010/11/21/135/ -- /* * We used to try various strange things. Let's not. */ 2.2.16 /usr/src/linux/fs/buffer.c