guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Potluck dish - Simple functional reactive programming


From: Ludovic Courtès
Subject: Re: Potluck dish - Simple functional reactive programming
Date: Sun, 16 Feb 2014 20:06:21 +0100
User-agent: Gnus/5.130007 (Ma Gnus v0.7) Emacs/24.3 (gnu/linux)

David Thompson <address@hidden> skribis:

> This code isn't terrible, but wouldn't it be nice to declare that
> 'gc-label' will always contain a string with the number of GC runs in
> it instead?  Enter FRP:
>
> (define gc-label-position (vector2 0 40))
> (define gc-counter (make-root-signal 0))
> (define gc-label
>   (signal-map (lambda (counter)
>                 (let ((text (format #f "GCs: ~d" counter)))
>                   (make-label font text gc-label-position)))
>               gc-counter))
>
> (add-hook! after-gc-hook
>            (lambda ()
>              (signal-set! gc-counter (1+ (signal-ref gc-counter)))))

Neat!  I’m a big fan.

I think we should consider adding an FRP module to Guile eventually.

Cheers,
Ludo’.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]