[fluxus] frame hook
Artem Baguinski
femistofel at gmail.com
Sat Feb 18 06:19:25 PST 2006
Hi
I have reimplemented the "every-frame" functionality using guile
hooks and a macro. The performance gain is probably neglegible but it
gives me a better feeling when coding.
The patch removes "every-frame" altogether, instead there is a new
function: "frame-hook" which returns a guile hook (see Guile
Reference Part IV >> Utility Functions >> Hooks) which is run each
frame.
example usage:
was:
(every-frame "(alter 6)(rotate-heaven)")
now [1]:
(add-hook! (frame-hook) (lambda () (alter 6)(rotate-heaven)))
or:
;; have to add backwards becase "add-hook!" prepends ...
(add-hook! (frame-hook) rotate-heaven)
(add-hook! (frame-hook) (lambda () (alter 6)))
or:
;; ... unless told otherwise (mind #t)
(add-hook! (frame-hook) (lambda () (alter 6)) #t)
(add-hook! (frame-hook) rotate-heaven #t)
OMFG!!! That's much more typing!!!
That's why I also wrote a macro which will allows the following:
(every-frame
(alter 6)
(rotate-heaven))
The macro expands into form [1].
You'll have to define that macro in your ~/.fluxus.scm or is there
some "site-lisp" sort of place? (i never installed fluxus, just run
it from xcode, so i don't know where the "scm" thing goes).
Anyway, the implementation of the macro:
(use-syntax (ice-9 syncase)) ; for R5RS macros
(define-syntax every-frame
(syntax-rules ()
((every-frame expr1 ...)
(let ((h (frame-hook)))
(add-hook! h
(lambda () expr1 ...))))))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: frame-hook.patch
Type: application/octet-stream
Size: 3765 bytes
Desc: not available
URL: <http://lists.pawfal.org/pipermail/fluxus-pawfal.org/attachments/20060218/9f559b32/attachment-0001.obj>
-------------- next part --------------
More information about the Fluxus
mailing list