Issue 6
0. Introduction
Welcome to issue 6 of the Chicken Gazette, today brought to you by Felix Winkelmann.
1. The Hatching Farm - New Eggs & The Egg Repository
Much work has been done related to GUI programming with Chicken:
Thomas Chust made bindings for the IUP GUI toolkit available, which is provided in the iup egg. IUP is very portable and easy to use, so give it a try if you are (like me) looking for the perfect GUI library and have (like me) not found it, yet. Thomas' development repository can be found at http://www.chust.org/fossils/iup.
Andrei Barbu is working on Smoke bindings for Chicken! Check out the work in progress at http://0xab.com/code/smoke.git.
Peter Bex ported Dorai Sitarams slatex package.
Peter Lane added support for the leptonica image processing library.
And last, but not least, Joerg Wittenberger provided a more reliable SRFI-34 implementation that plays better with multithreading (to be added to the repository soon).
2. The Core - Bleeding Edge Development
- Peter Bex detected a bug in the build-system related to the use of alloca.h on BSD systems
- Parameters now have SRFI-17 setters
- Local syntax bindings didn't recover literal identifier that where shadowed by surrounding lexical bindings (thanks to Peter Bex for providing a minimal testcase)
- chicken-install -r now works when used in combination with a local repository checkout (suggested by Mario Domenech Goulart)
- installation-prefix is now treated correctly for deployment mode and when cross-compiling
- Bugfixes in SRFI-4 library
Note that all these changes have been committed to the "experimental" branch and are not officially released. These and the quite extensive changes made last week will soon be available in a new development snapshot (4.6.2) which needs more testing before it can be pushed to "master".
3. Chicken Talk
The GUI stuff mentioned above was announced and received with great interest and Peter Bex suggested extending the functionality of chicken-install to add support for egg-specific data-directories in the repository for locally installed extensions.
Jim Pryor, who is packaging eggs for ArchLinux provided an extensive list of fixes for various extensions that don't play well with non-standard installation-directories. It must be added that this is doing a tremendous service for us - bulk packaging provides an opportunity for vetting the installation process and extension-dependencies, something we are already doing in a fully automated fashion with Mario's excellent salmonella, but building eggs for packaging has more restrictive demands on things like installation locations.
4. Omelette Recipes - Tips and Tricks
This time I would like to point out the miscmacros extension, which contains a number of convenient syntax definitions for many sorts of things. In addition to the usual looping macros (while, repeat), anaphoric if and forms known from Common Lisp (like dotimes, ignore-errors and begin0, a Scheme version of CL's prog1), this extension also holds some other rather handy and practical things.
A favorite of mine is for example define-syntax-rule, a shorter alternative to define-syntax + syntax-rules:
(define-syntax-rule (while test body ...)
(let loop ()
(when test (begin body ... (loop)))))
This is much shorter and arguably clearer than:
(define-syntax while
(syntax-rules ()
((_ test body ...)
(let loop ()
(when test (begin body ... (loop)))))))
Also check out doto, a macro that some might know from the Clojure Lisp dialect:
(doto (some-data) (init-data) (show-data window) (throw-away-data)) ; expands to: (let ((tmp (some-data))) (init-data tmp) (show-data tmp window) (throw-away-data tmp) tmp)
miscmacros also provides forms that perform side effects on so called "generalized locations", similar to Common Lisp's setf but more dynamic and easier to use:
(define counter 0) (inc! counter) counter => 1 (define-record-type stack (make-stack elements) stack? (elements stack-elements (setter stack-elements))) ; CHICKEN-specific extension (define s1 (make-stack '())) (push! 1 (stack-elements s1)) (push! 2 (stack-elements s2)) (stack-elements s1) => (2 1)
Note that the location argument to push! or inc! allows any procedure with an associated setter procedure to be used as a generalized location:
(define se stack-element) (push! some-value (se s1))
or even
(inc! (file-modification-time "foo.scm") 5) ; increase mtime by 5 seconds
The magic that makes this work is a combination of SRFI-17 "setters" and the modify-location syntax, which is also part of miscmacros:
(define-syntax-rule (increment! loc)
(modify-location
loc
(lambda (ref upd) (upd (add1 (ref)))) ) )
modify-location takes a generalized location and a procedure with two arguments, a read- and a write procedure that are used to load the existing value and writes a modified version of the value. It handles the case when the location is a variable and also takes care of evaluating the arguments to the location procedure (in case it is one) only once:
(inc! (f32vector-ref big-vector (read))) ; will only call `read' once
Side note: modify-location and setters appear to have originated in the fascinating T Scheme implementation, which is well worth studying. In particular, the T object system is a refreshing and inventive look at object oriented programming in Lisp. CHICKEN-users of course just enter
% chicken-install operations
and use it right away!
5. About the Chicken Gazette
The Gazette is produced weekly by a volunteer from the Chicken community. The latest issue can be found at http://gazette.call-cc.org or you can follow it in your feed reader at http://gazette.call-cc.org/feed.atom. If you'd like to write an issue, check out the instructions and come and find us in #chicken on Freenode!