From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.user Subject: Re: Signals / Messages / Events / ...? Date: Wed, 3 Jan 2018 11:53:33 +0000 Message-ID: References: <1514956159.4049.2.camel@qlfiles.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1514980326 27010 195.159.176.226 (3 Jan 2018 11:52:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 3 Jan 2018 11:52:06 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Jan 03 12:52:02 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 1eWhaS-0006gS-Vh for guile-user@m.gmane.org; Wed, 03 Jan 2018 12:52:01 +0100 Original-Received: from localhost ([::1]:49899 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWhcR-0004xa-Vm for guile-user@m.gmane.org; Wed, 03 Jan 2018 06:54:04 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWhc6-0004xT-Ar for guile-user@gnu.org; Wed, 03 Jan 2018 06:53:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWhc3-0002wr-23 for guile-user@gnu.org; Wed, 03 Jan 2018 06:53:42 -0500 Original-Received: from smtp-out-2.talktalk.net ([62.24.135.66]:55781) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eWhc2-0002w4-SK for guile-user@gnu.org; Wed, 03 Jan 2018 06:53:38 -0500 Original-Received: from arudy.520b.com ([79.67.189.94]) by smtp.talktalk.net with SMTP id Whbze6dytNSVVWhbzet0sN; Wed, 03 Jan 2018 11:53:36 +0000 X-Originating-IP: [79.67.189.94] X-Spam: 0 X-OAuthority: v=2.2 cv=NYGW7yL4 c=1 sm=1 tr=0 a=6gAC+NpqxJQpkC8RWOoUjw==:117 a=6gAC+NpqxJQpkC8RWOoUjw==:17 a=IkcTkHD0fZMA:10 a=RgaUWeydRksA:10 a=iIBVl25HID_q4MU5NWgA:9 a=QEXdDO2ut3YA:10 Original-Received: from [10.37.7.107] (unknown [213.86.221.35]) by arudy.520b.com (Postfix) with ESMTPSA id 2D20A38081 for ; Wed, 3 Jan 2018 11:53:35 +0000 (GMT) In-Reply-To: <1514956159.4049.2.camel@qlfiles.net> Content-Language: en-US X-CMAE-Envelope: MS4wfIzjpenXLfE6nOzBME8Xt7nI5Av53zZwOcEDEus0woFwIK2XQF/0IL6kCPCR5eECZcQdpo6Wy/A/PdoV0EqZr207BuHpzjqy2h+8rNXzXRi6WxFC8RuI P9FILHqVD1VNO9LLnqIK7Rf+SvN+OpbH1BeYx4Fmcb2J2kXHmicaeNXZ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 62.24.135.66 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:14400 Archived-At: On 03/01/18 05:09, Christopher Howard wrote: > Hi list, forgive me if this is a somewhat vague question... but is > there some kind of framework/system/approach for Guile where you could > have different parts of your code register callback functions to react > to a certain signal or message raised by any other part of the code? > I'm thinking like dbus where I guess you can sort of send off a message > but not really care who receives it. In chickadee you can register > callbacks for the various input events, and i think that basic idea > could be extended so long as (1) you could have any kind of > event/signal you wanted; (2) call backs added could be specified as > either persistent or one-time call-backs. > > It seems like it wouldn't be too hard to code something like that with > just lists of callback functions tied to names/data in a tree. But > maybe somebody has already thought of that or would suggest a better > approach. > > Just running into this challenge in development where a function like > "new-game" has to do 8 different things to 6 different data structures, > but why not instead just have the code dealing with the 6 different > objects register callbacks to receive the 'new-game signal? I think > message passing is the wrong term because in message passing you > specify the message connections between the different objects, right? > Signal bus maybe? > Well, one Lispy mechanism in that area is hooks.  For example, from some of my old code: ;; Changes to modem registration state are indicated by calling this ;; hook with args STATE and PROPERTIES.  STATE can be 'none, meaning ;; that there is currently no modem; 'unregistered, meaning that there ;; is a modem but it isn't registered with the network; or ;; 'registered, meaning that the modem is registered with the network. ;; If STATE is 'registered, PROPERTIES is an alist of registration ;; properties; otherwise PROPERTIES is #f. (define registration-hook (make-hook 2)) (define (add-registration-hook proc)   (add-hook! registration-hook proc)) (define (notify-registration state properties)   (run-hook registration-hook state properties)) Does that serve your purpose at all? Best wishes - Neil