chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] CHICKEN Gazette, Issue 6


From: Felix
Subject: [Chicken-users] CHICKEN Gazette, Issue 6
Date: Mon, 04 Oct 2010 03:48:26 -0400 (EDT)

     _/_/_/  _/        _/            _/
  _/        _/_/_/          _/_/_/  _/  _/      _/_/    _/_/_/
 _/        _/    _/  _/  _/        _/_/      _/_/_/_/  _/    _/
_/        _/    _/  _/  _/        _/  _/    _/        _/    _/
 _/_/_/  _/    _/  _/    _/_/_/  _/    _/    _/_/_/  _/    _/

--[ Issue 6 ]-------------------------------------- G A Z E T T E
                               brought to you by the CHICKEN Team


== 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 (http://wiki.call-cc.org/users/thomas-chust) made bindings for
the IUP (http://tecgraf.puc-rio.br/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
(http://techbase.kde.org/Development/Languages/Smoke) bindings for CHICKEN!
Check out the work in progress at http://0xab.com/code/smoke.git.

Peter Bex (http://wiki.call-cc.org/users/peter-bex) ported Dorai Sitarams
`slatex` package.

Peter Lane (http://wiki.call-cc.org/users/peter-lane) added support for the
leptonica (http://www.leptonica.com) 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 (http://archlinux.org) 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 (http://tests.call-cc.org), 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
(http://srfi.schemers.org/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 (http://mumble.net/~jar/tproject/) 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
(http://bugs.call-cc.org/browser/gazette/README.txt) and come and find us in
#chicken on Freenode!

[ --- End of this issue --- ]



reply via email to

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