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 19:53:28 +0000 Message-ID: References: <1514956159.4049.2.camel@qlfiles.net> <1514992280.4049.5.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 1515009135 30244 195.159.176.226 (3 Jan 2018 19:52:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 3 Jan 2018 19:52:15 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 To: Christopher Howard , guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Jan 03 20:52:11 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 1eWp51-00078A-Eh for guile-user@m.gmane.org; Wed, 03 Jan 2018 20:52:03 +0100 Original-Received: from localhost ([::1]:34874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWp6z-0004B3-6A for guile-user@m.gmane.org; Wed, 03 Jan 2018 14:54:05 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWp6X-0004An-QL for guile-user@gnu.org; Wed, 03 Jan 2018 14:53:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWp6S-0004LB-UJ for guile-user@gnu.org; Wed, 03 Jan 2018 14:53:37 -0500 Original-Received: from smtp-out-2.talktalk.net ([62.24.135.66]:35331) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eWp6S-0004HO-Nv for guile-user@gnu.org; Wed, 03 Jan 2018 14:53:32 -0500 Original-Received: from arudy.520b.com ([79.67.189.94]) by smtp.talktalk.net with SMTP id Wp6Qe85L2NSVVWp6QetGpu; Wed, 03 Jan 2018 19:53:30 +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=EBKDh9UIUDZYZXCZttYA:9 a=QEXdDO2ut3YA:10 Original-Received: from [192.168.1.13] (unknown [192.168.1.13]) by arudy.520b.com (Postfix) with ESMTPSA id B679538081; Wed, 3 Jan 2018 19:53:29 +0000 (GMT) In-Reply-To: <1514992280.4049.5.camel@qlfiles.net> Content-Language: en-US X-CMAE-Envelope: MS4wfKQQmx+auYl13QbbStKryOvwYXNUj7W0Uby/rQ/+Qgl/GOmtvyOzVvxLBSzlr9iCLZWtEMkQSkBy+uYnQWtVpNarxvLUQO1sBtCub0NZmq7HXoxFmfkP zHaZCBX55AFAfaTufeSU95xnTMhdzvd5euh/nwYophnkkEpAjWVqbwUOdlbsCqSwA3Zl87SW9FjJMcxIDaE5rS6m4QZKcII5cGfxibCh3mUr54/HNFWRnLA7 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:14402 Archived-At: On 03/01/18 15:11, Christopher Howard wrote: > On Wed, 2018-01-03 at 11:53 +0000, Neil Jerram wrote: >> 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 >> >> > I think that should work. Only part I'm not sure about is if you can > have a "one-off" procedure added to a hook... but you could just have > the procedure call remove-hook! to remove itself...? > Yes, I think so, and you could encapsulate that with something like this: (define (add-hook-once-only! hook proc)   (letrec ((proc-once-only             (lambda args               (remove-hook! hook proc-once-only)               (apply proc args))))     (add-hook! hook proc-once-only))) Best wishes - Neil