From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Thompson Newsgroups: gmane.lisp.guile.user Subject: Re: Potluck dish - Simple functional reactive programming Date: Mon, 17 Feb 2014 20:17:18 -0500 Message-ID: <87a9dpxlr5.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me> References: <87ob26x61e.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1392686401 28906 80.91.229.3 (18 Feb 2014 01:20:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Feb 2014 01:20:01 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Feb 18 02:20:09 2014 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 1WFZM1-0001Xa-7s for guile-user@m.gmane.org; Tue, 18 Feb 2014 02:20:09 +0100 Original-Received: from localhost ([::1]:45485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFZM0-0001S6-BU for guile-user@m.gmane.org; Mon, 17 Feb 2014 20:20:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFZJS-000705-Uy for guile-user@gnu.org; Mon, 17 Feb 2014 20:17:37 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFZJM-0007kU-N3 for guile-user@gnu.org; Mon, 17 Feb 2014 20:17:30 -0500 Original-Received: from na3sys009aog116.obsmtp.com ([74.125.149.240]:34405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFZJM-0007kB-9o for guile-user@gnu.org; Mon, 17 Feb 2014 20:17:24 -0500 Original-Received: from mail-qc0-f172.google.com ([209.85.216.172]) (using TLSv1) by na3sys009aob116.postini.com ([74.125.148.12]) with SMTP ID DSNKUwK0oQVPzTEyjdq6XVD9mTWb5Z4h2Iyy@postini.com; Mon, 17 Feb 2014 17:17:24 PST Original-Received: by mail-qc0-f172.google.com with SMTP id c9so25081111qcz.3 for ; Mon, 17 Feb 2014 17:17:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-type; bh=/cJ6h3HQYgVMrHbWaySlRcuOE/4ouIUbVxsVdeNCuRU=; b=edd3+m5dB8lUemffMKWn4wRzHD0y3PTP1LgZKf1bNG+PblF8CS9b7bFVdSEtq5bq8P bdFQ8t8mUqoFExV8F2eYpileonm/QT9IxnnMLloux0H0Uaui6Dx9FVi6mRySD4nYhNvc p5fhPgxM+ynflR7v64nd90w1SQsyUSVMdaVQBww0R3cwPwP0llOF/3Fv43BJbnzTcYtn Bn9i7/V83cJN74zQzLpZBwwzq4y9uO+PSwHfCsCSQq/gsaS5WZLz56zv9erey2cRhnIp RMN3f1BBUG2eUeX9OjAIL6SmbD7IzNc/QcNuy6VGIkN5ARVZ+RnMhPBm9aoddGmb8I+R hlwA== X-Gm-Message-State: ALoCoQk7UdJn10YRuWbTqs1zwXmAnse0muB+N3DJDnVh86emACaODlYv2pcO4q/BTSoXRL1x/TmakIc8UZ/V3rWmxV74pgHlcTzND8ykqgSwb+7jMz29pITYEupJWGwIUtEUubNO10fjyILlBLeUBOsgsfCYoTzECA== X-Received: by 10.140.25.142 with SMTP id 14mr6448211qgt.83.1392686241266; Mon, 17 Feb 2014 17:17:21 -0800 (PST) X-Received: by 10.140.25.142 with SMTP id 14mr6448190qgt.83.1392686241031; Mon, 17 Feb 2014 17:17:21 -0800 (PST) Original-Received: from izanagi (209-6-40-86.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com. [209.6.40.86]) by mx.google.com with ESMTPSA id z18sm9568698qab.5.2014.02.17.17.17.19 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 17 Feb 2014 17:17:19 -0800 (PST) In-Reply-To: <87ob26x61e.fsf@izanagi.i-did-not-set--mail-host-address--so-tickle-me> User-Agent: Notmuch/0.17 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 74.125.149.240 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:11071 Archived-At: --=-=-= Content-Type: text/plain David Thompson writes: > Lately I've been playing around with functional reactive programming > (FRP) applied to video games. This style of programming allows for a > declarative, functional way of describing time-varying values. Contrast > this method of programming with more traditional hooks and callbacks. > My FRP module can be used on top of hooks to escape callback hell. I spent the day improving my potluck dish. The public API remains the same, but the implementation is quite a bit different. The previous implementation suffered from 2 major flaws: 1) The GC would never collect orphaned signals because of the doubly linked structure of the graph 2) Redefining a signal 'foo' at the REPL doesn't splice the new value of 'foo' into the graph where the old value of 'foo' was. Thus, working with signals at the REPL was painful. So, this new implementation uses an additional data type called to deal with the dynamic nature of REPL-driven development. The user is always working with signal boxes, not the signals themselves. By using the 'define-signal' macro, redefining the signal 'foo' at the REPL will replace the contents of the box with the new signal. If any other signals depended on 'foo', they automagically begin to work with the signal within the box 'foo'. To deal with doubly linked nodes, a weak key hash table is used to store signal outputs. This allows input signals to push values to output signals without protecting them from the clutches of the garbage collector. When an output signal is no longer referenced, the input signal will stop pushing new values to it. Here's the updated version of the example from last time. Note that using 'after-gc-hook' is actually a bad idea, but I did it anyway. ;) (define-signal gc-counter (make-signal 0)) (define-signal gc-label (signal-map (lambda (counter) (let ((text (format #f "GCs: ~d" counter))) (make-label font text (vector2 0 40)))) gc-counter)) (add-hook! after-gc-hook (lambda () (schedule game-agenda (lambda () (signal-set! gc-counter (1+ (signal-ref gc-counter))))))) This module is currently part of the wip-frp branch of the guile-2d repo on gitorious. https://gitorious.org/guile-2d/guile-2d/source/3a786ddee63d4505cdb142442e880950698223f0:2d/signal.scm Thanks for following along, - David Thompson --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=signal.scm Content-Transfer-Encoding: base64 Ozs7IGd1aWxlLTJkCjs7OyBDb3B5cmlnaHQgKEMpIDIwMTMsIDIwMTQgRGF2aWQgVGhvbXBzb24g PGR0aG9tcHNvbjJAd29yY2VzdGVyLmVkdT4KOzs7Cjs7OyBHdWlsZS0yZCBpcyBmcmVlIHNvZnR3 YXJlOiB5b3UgY2FuIHJlZGlzdHJpYnV0ZSBpdCBhbmQvb3IgbW9kaWZ5IGl0Cjs7OyB1bmRlciB0 aGUgdGVybXMgb2YgdGhlIEdOVSBMZXNzZXIgR2VuZXJhbCBQdWJsaWMgTGljZW5zZSBhcwo7Ozsg cHVibGlzaGVkIGJ5IHRoZSBGcmVlIFNvZnR3YXJlIEZvdW5kYXRpb24sIGVpdGhlciB2ZXJzaW9u IDMgb2YgdGhlCjs7OyBMaWNlbnNlLCBvciAoYXQgeW91ciBvcHRpb24pIGFueSBsYXRlciB2ZXJz aW9uLgo7OzsKOzs7IEd1aWxlLTJkIGlzIGRpc3RyaWJ1dGVkIGluIHRoZSBob3BlIHRoYXQgaXQg d2lsbCBiZSB1c2VmdWwsIGJ1dAo7OzsgV0lUSE9VVCBBTlkgV0FSUkFOVFk7IHdpdGhvdXQgZXZl biB0aGUgaW1wbGllZCB3YXJyYW50eSBvZgo7OzsgTUVSQ0hBTlRBQklMSVRZIG9yIEZJVE5FU1Mg Rk9SIEEgUEFSVElDVUxBUiBQVVJQT1NFLiAgU2VlIHRoZSBHTlUKOzs7IExlc3NlciBHZW5lcmFs IFB1YmxpYyBMaWNlbnNlIGZvciBtb3JlIGRldGFpbHMuCjs7Owo7OzsgWW91IHNob3VsZCBoYXZl IHJlY2VpdmVkIGEgY29weSBvZiB0aGUgR05VIExlc3NlciBHZW5lcmFsIFB1YmxpYwo7OzsgTGlj ZW5zZSBhbG9uZyB3aXRoIHRoaXMgcHJvZ3JhbS4gIElmIG5vdCwgc2VlCjs7OyA8aHR0cDovL3d3 dy5nbnUub3JnL2xpY2Vuc2VzLz4uCgo7OzsgQ29tbWVudGFyeToKOzsKOzsgU2ltcGxlIGZ1bmN0 aW9uYWwgcmVhY3RpdmUgcHJvZ3JhbW1pbmcgQVBJLgo7Owo7OzsgQ29kZToKCihkZWZpbmUtbW9k dWxlICgyZCBzaWduYWwpCiAgIzp1c2UtbW9kdWxlIChzcmZpIHNyZmktMSkKICAjOnVzZS1tb2R1 bGUgKHNyZmkgc3JmaS05KQogICM6dXNlLW1vZHVsZSAoc3JmaSBzcmZpLTI2KQogICM6dXNlLW1v ZHVsZSAoMmQgYWdlbmRhKQogICM6ZXhwb3J0IChzaWduYWw/CiAgICAgICAgICAgIG1ha2Utc2ln bmFsCiAgICAgICAgICAgIGRlZmluZS1zaWduYWwKICAgICAgICAgICAgaG9vay0+c2lnbmFsCiAg ICAgICAgICAgIHNpZ25hbC1yZWYKICAgICAgICAgICAgc2lnbmFsLXJlZi1tYXliZQogICAgICAg ICAgICBzaWduYWwtc2V0IQogICAgICAgICAgICBzaWduYWwtcHJvYwogICAgICAgICAgICBzaWdu YWwtbWVyZ2UKICAgICAgICAgICAgc2lnbmFsLWNvbWJpbmUKICAgICAgICAgICAgc2lnbmFsLW1h cAogICAgICAgICAgICBzaWduYWwtZm9sZAogICAgICAgICAgICBzaWduYWwtZmlsdGVyCiAgICAg ICAgICAgIHNpZ25hbC1yZWplY3QKICAgICAgICAgICAgc2lnbmFsLWNvbnN0YW50CiAgICAgICAg ICAgIHNpZ25hbC1jb3VudAog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JlbnQtdmFsdWUpCiAgICAgIChhcHBseSBwcm9j IChtYXAgc2lnbmFsLXJlZiBpbnB1dHMpKSkKICAgIChtYWtlLWJveGVkLXNpZ25hbCAoY3VycmVu dC12YWx1ZSkKICAgICAgICAgICAgICAgICAgICAgICAobGFtYmRhIChzZWxmIHZhbHVlKQogICAg ICAgICAgICAgICAgICAgICAgICAgKCVzaWduYWwtc2V0ISBzZWxmIChjdXJyZW50LXZhbHVlKSkp CiAgICAgICAgICAgICAgICAgICAgICAgaW5wdXRzKSkpCgooZGVmaW5lIChzaWduYWwtZm9sZCBw cm9jIGluaXQgc2lnbmFsIC4gcmVzdCkKICAiQ3JlYXRlIGEgbmV3IHNpZ25hbCB0aGF0IGFwcGxp ZXMgUFJPQyB0byB0aGUgdmFsdWVzIHN0b3JlZCBpbgpTSUdOQUwuIFBST0MgaXMgYXBwbGllZCB3 aXRoIHRoZSBjdXJyZW50IHZhbHVlIG9mIFNJR05BTCBhbmQgdGhlCnByZXZpb3VzbHkgY29tcHV0 ZWQgdmFsdWUsIG9yIElOSVQgZm9yIHRoZSBmaXJzdCBjYWxsLiIKICAobGV0ICgoaW5wdXRzIChj b25zIHNpZ25hbCByZXN0KSkpCiAgICAobWFrZS1ib3hlZC1zaWduYWwgaW5pdAogICAgICAgICAg ICAgICAgICAgICAgIChsZXQgKChwcmV2aW91cyBpbml0KSkKICAgICAgICAgICAgICAgICAgICAg ICAgIChsYW1iZGEgKHNlbGYgdmFsdWUpCiAgICAgICAgICAgICAgICAgICAgICAgICAgIChsZXQg KCh4IChhcHBseSBwcm9jCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAoYXBwZW5kIChtYXAgc2lnbmFsLXJlZiBpbnB1dHMpCiAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgIChsaXN0IHByZXZpb3VzKSkpKSkKICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAoc2V0ISBwcmV2aW91cyB4KQogICAgICAgICAgICAgICAgICAg ICAgICAgICAgICglc2lnbmFsLXNldCEgc2VsZiB4KSkpKQogICAgICAgICAgICAgICAgICAgICAg IGlucHV0cykpKQoKKGRlZmluZSAoc2lnbmFsLWZpbHRlciBwcmVkaWNhdGUgZGVmYXVsdCBzaWdu YWwpCiAgIkNyZWF0ZSBhIG5ldyBzaWduYWwgdGhhdCBrZWVwcyBhbiBpbmNvbWluZyB2YWx1ZSBm cm9tIFNJR05BTCB3aGVuCml0IHNhdGlmaWVzIHRoZSBwcm9jZWR1cmUgUFJFRElDQVRFLiAgVGhl IHZhbHVlIG9mIHRoZSBzaWduYWwgaXMKREVGQVVMVCB3aGVuIHRoZSBwcmVkaWNhdGUgaXMgbmV2 ZXIgc2F0aXNmaWVkLiIKICAobWFrZS1ib3hlZC1zaWduYWwgKGlmIChwcmVkaWNhdGUgKHNpZ25h bC1yZWYgc2lnbmFsKSkKICAgICAgICAgICAgICAgICAgICAgICAgIChzaWduYWwtcmVmIHNpZ25h bCkKICAgICAgICAgICAgICAgICAgICAgICAgIGRlZmF1bHQpCiAgICAgICAgICAgICAgICAgICAg IChsYW1iZGEgKHNlbGYgdmFsdWUpCiAgICAgICAgICAgICAgICAgICAgICAgKHdoZW4gKHByZWRp Y2F0ZSB2YWx1ZSkKICAgICAgICAgICAgICAgICAgICAgICAgICglc2lnbmFsLXNldCEgc2VsZiB2 YWx1ZSkpKQogICAgICAgICAgICAgICAgICAgICAobGlzdCBzaWduYWwpKSkKCihkZWZpbmUgKHNp Z25hbC1yZWplY3QgcHJlZGljYXRlIGRlZmF1bHQgc2lnbmFsKQogICJDcmVhdGUgYSBuZXcgc2ln bmFsIHRoYXQgZG9lcyBub3Qga2VlcCBhbiBpbmNvbWluZyB2YWx1ZSBmcm9tClNJR05BTCB3aGVu IGl0IHNhdGlzZmllcyB0aGUgcHJvY2VkdXJlIFBSRURJQ0FURS4gIFRoZSB2YWx1ZSBvZiB0aGUK c2lnbmFsIGlzIERFRkF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kYSAoeCkgKHByb2MgeCkgeCkgc2lnbmFsKSkKCihkZWZpbmUgKHNpZ25hbC1zYW1wbGUgYWdl bmRhIGRlbGF5IHNpZ25hbCkKICAiQ3JlYXRlIGEgbmV3IHNpZ25hbCB0aGF0IGVtaXRzIHRoZSB2 YWx1ZSBjb250YWluZWQgd2l0aGluIFNJR05BTApldmVyeSBERUxBWSB0aWNrcyBvZiBBR0VOREEu IgogIChsZXQgKChzYW1wbGVyICglbWFrZS1zaWduYWwgKHNpZ25hbC1yZWYgc2lnbmFsKSAjZiAn KCkpKSkKICAgIChkZWZpbmUgKHRpY2spCiAgICAgICglc2lnbmFsLXNldCEgc2FtcGxlciAoc2ln bmFsLXJlZiBzaWduYWwpKSkKICAgIChzY2hlZHVsZS1pbnRlcnZhbCBhZ2VuZGEgdGljayBkZWxh eSkKICAgIChtYWtlLXNpZ25hbC1ib3ggc2FtcGxlcikpKQoKKGRlZmluZSAoc2lnbmFsLWRlbGF5 IGFnZW5kYSBkZWxheSBzaWduYWwpCiAgIkNyZWF0ZSBhIG5ldyBzaWduYWwgdGhhdCBkZWxheXMg cHJvcGFnYXRpb24gb2YgU0lHTkFMIGJ5IERFTEFZCnRpY2tzIG9mIEFHRU5EQS4iCiAgKG1ha2Ut Ym94ZWQtc2lnbmFsIChzaWduYWwtcmVmIHNpZ25hbCkKICAgICAgICAgICAgICAgICAgICAgKGxh bWJkYSAoc2VsZiB2YWx1ZSkKICAgICAgICAgICAgICAgICAgICAgICAoc2NoZWR1bGUgYWdlbmRh CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChsYW1iZGEgKCkKICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAoJXNpZ25hbC1zZXQhIHNlbGYgdmFsdWUpKQogICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICBkZWxheSkpCiAgICAgICAgICAgICAgICAgICAgIChs aXN0IHNpZ25hbCkpKQoKKGRlZmluZSAoc2lnbmFsLXRocm90dGxlIGFnZW5kYSBkZWxheSBzaWdu YWwpCiAgIlJldHVybiBhIG5ldyBzaWduYWwgdGhhdCBwcm9wYWdhdGVzIFNJR05BTCBhdCBtb3N0 IG9uY2UgZXZlcnkgREVMQVkKdGlja3Mgb2YgQUdFTkRBLiIKICAobWFrZS1ib3hlZC1zaWduYWwg KHNpZ25hbC1yZWYgc2lnbmFsKQogICAgICAgICAgICAgICAgICAgICAobGV0ICgobGFzdC10aW1l IChhZ2VuZGEtdGltZSBhZ2VuZGEpKSkKICAgICAgICAgICAgICAgICAgICAgICAobGFtYmRhIChz ZWxmIHZhbHVlKQogICAgICAgICAgICAgICAgICAgICAgICAgKHdoZW4gKD49ICgtIChhZ2VuZGEt dGltZSBhZ2VuZGEpIGxhc3QtdGltZSkgZGVsYXkpCiAgICAgICAgICAgICAgICAgICAgICAgICAg ICglc2lnbmFsLXNldCEgc2VsZiB2YWx1ZSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgKHNl dCEgbGFzdC10aW1lIChhZ2VuZGEtdGltZSBhZ2VuZGEpKSkpKQogICAgICAgICAgICAgICAgICAg ICAobGlzdCBzaWduYWwpKSkK --=-=-=--