chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] Chicken Gazette - Issue 10


From: Mario Domenech Goulart
Subject: [Chicken-users] Chicken Gazette - Issue 10
Date: Mon, 01 Nov 2010 07:21:33 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux)

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

--[ Issue 10 ]------------------------------------- G A Z E T T E
                               brought to you by the Chicken Team


== 0. Introduction

Welcome to issue 10 of the Chicken Gazette!


== 1. The Hatching Farm

It has been a fruitful week for the egg repository: three new eggs and lots
of bug fixes and improvements.

Moritz Heidkamp (http://wiki.call-cc.org/users/moritz-heidkamp) has created
the zmq (http://wiki.call-cc.org/egg/zmq) egg, which contains bindings for
the ZeroMQ (http://www.zeromq.org/) library.

Felix Winkelmann (http://wiki.call-cc.org/users/felix-winkelmann) has ported
Marc Feeley's tar (http://snow.iro.umontreal.ca/?viewpkg=tar) implementation
from the Scheme Now (Snow) (http://snow.iro.umontreal.ca) project to Chicken,
available as a chicken egg called snowtar.

Alan Post has created the genturfahi (http://wiki.call-cc.org/egg/genturfahi)
egg, a Scheme packrat parser.

Jim Ursetto (http://wiki.call-cc.org/users/jim-ursetto) released chickadee
(http://wiki.call-cc.org/egg/chickadee) 0.9.8.2, which contains a fix for the
iOS 4.1 offset bug.

Felix Winkelmann (http://wiki.call-cc.org/users/felix-winkelmann)
has added static linking support support for the following
eggs: json (http://wiki.call-cc.org/egg/json), base64
(http://wiki.call-cc.org/egg/base64) and environments
(http://wiki.call-cc.org/egg/environments).

Peter Bex (http://wiki.call-cc.org/users/peter-bex) has fixed
a serious issue in Spiffy (http://wiki.call-cc.org/egg/spiffy),
the Chicken web server. As Peter noticed in his message
(http://lists.nongnu.org/archive/html/chicken-users/2010-10/msg00171.html)
to the chicken-users (http://lists.nongnu.org/mailman/listinfo/chicken-users)
mailing list, earlier versions (i.e., 4.8 and older) are not affected by that
bug. Spiffy users are encouraged to upgrade from version 4.9 to 4.10 (which
also includes a fix for handling empty path components that are now preserved
by uri-generic (http://wiki.call-cc.org/egg/uri-generic)).

Several eggs have been updated with minor changes:
signal-diagram, make (http://wiki.call-cc.org/egg/make),
fast-generic (http://wiki.call-cc.org/egg/fast-generic),
vandusen, html-tags (http://wiki.call-cc.org/egg/html-tags),
srfi-27 (http://wiki.call-cc.org/egg/srfi-27), message-digest
(http://wiki.call-cc.org/egg/message-digest), simple-units
(http://wiki.call-cc.org/egg/simple-units), error-utils
(http://wiki.call-cc.org/egg/error-utils), interval-digraph,
getopt-long (http://wiki.call-cc.org/egg/getopt-long),
format-textdiff (http://wiki.call-cc.org/egg/format-textdiff),
filepath (http://wiki.call-cc.org/egg/filepath), digraph
(http://wiki.call-cc.org/egg/digraph), moremacros
(http://wiki.call-cc.org/egg/moremacros), sigma
(http://wiki.call-cc.org/egg/sigma), nemo (http://wiki.call-cc.org/egg/nemo),
miniML, json-abnf (http://wiki.call-cc.org/egg/json-abnf),
npdiff (http://wiki.call-cc.org/egg/npdiff), html-form
(http://wiki.call-cc.org/egg/html-form), ext-direct,
dict (http://wiki.call-cc.org/egg/dict), uri-dispatch
(http://wiki.call-cc.org/egg/uri-dispatch), and log5scm
(http://wiki.call-cc.org/egg/log5scm).

Several egg authors have adopted the exit status "protocol"
for tests (http://tests.call-cc.org) with salmonella
(http://wiki.call-cc.org/egg/salmonella). The tests are very
important for the robustness of eggs and Chicken itself. Since tests
are executed by the Chicken core code from the git master branch
(http://code.call-cc.org/cgi-bin/gitweb.cgi?p=chicken-core.git;a=shortlog;h=refs/heads/master)
they also help catching bugs in the compiler. So, adding tests to eggs not
only improves the quality of eggs themselves, but the whole Chicken system.


== 2. Yolklore

Our esteemed team leader (http://bugs.call-cc.org/ticket/332) and core
developer Felix Winkelmann (http://wiki.call-cc.org/users/felix-winkelmann)
has been put some work on the experimental branch
(http://code.call-cc.org/cgi-bin/gitweb.cgi?p=chicken-core.git;a=shortlog;h=refs/heads/experimental)
of the git repository for the Chicken core code.

Erik Falor has reported a bug (http://bugs.call-cc.org/ticket/418) in the
build system regarding to the relinking of `libchicken`, which has been fixed
by Felix.

Iruatã Souza has contributed a patch for basic proxy authentication for
`chicken-install`.

Alan Post reported a bug (https://bugs.call-cc.org/ticket/421) which affected
optional parameters in lambda lists, which was instantaneously fixed by
Felix.

Felix has also added a neat setter for `list-ref` and fixed some bugs in
`find-files`, `delete-directory` and blob read-syntax, among other fixes and
improvements.


== 3. Chicken Talk

Some Chicken developers are going to meet during the 5th edition of T-DOSE
(http://www.t-dose.org/), a free and yearly event held in The Netherlands to
promote use and development of Open Source Software. This year's event will
be held on 6 and 7 November 2010 at the Fontys University of Applied Science
in Eindhoven. If you plan to go to T-DOSE, visit the Chicken stand to meet
Chicken developers and enjoy some Chicken software demonstrations which are
planned for the event.

The chicken-users (http://lists.nongnu.org/mailman/listinfo/chicken-users)
mailing list has been quite active lately.

Christian Kellermann (http://wiki.call-cc.org/users/christian-kellermann)
has published the results of a survey
(http://lists.nongnu.org/archive/html/chicken-users/2010-10/msg00138.html)
he run to find out the platforms used by Chicken users. The survey results
publication was followed by even more late results, which showed that some
people are running Chicken on ARM architecture.

Felix Winkelmann (http://wiki.call-cc.org/users/felix-winkelmann) has started
a wish-list (http://wiki.call-cc.org/wish-list) page in the Chicken wiki
(http://wiki.call-cc.org). Users can write there suggestions and things they
would like to have in Chicken.

The thread started by Alan Post regarding to using mmap files as strings
(http://lists.nongnu.org/archive/html/chicken-users/2010-10/msg00111.html)
has continued, with several suggestions and comments. We are glad to have
Alan Post back to Chicken development and discussions.

Yi Dai asked
(http://lists.nongnu.org/archive/html/chicken-users/2010-10/msg00143.html)
about the interaction between the readline egg and
procedures line `read` and friends. Mario Domenech Goulart
(http://wiki.call-cc.org/users/mario-domenech-goulart) suggested a hack
(http://lists.nongnu.org/archive/html/chicken-users/2010-10/msg00144.html),
but Yi Dai said that he'd like something like Guile
(http://www.gnu.org/software/guile/guile.html)'s behavior.

Among the usual lurkers and talkative `#chicken` users, a nice surprise was
the presence of Daishi Kato (http://wiki.call-cc.org/users/daishi-kato), a
long time Chicken user and developer.


== 4. Omelette Recipes - Tips and Tricks

For this omelette recipe I'll try to follow Jim
(http://wiki.call-cc.org/users/jim-ursetto)'s mom advice ("write
what you know") and show you a little example with a mix of
two eggs: awful (http://wiki.call-cc.org/egg/awful) and sandbox
(http://wiki.call-cc.org/egg/sandbox).

awful (http://wiki.call-cc.org/egg/awful) is a web framework built on top of
Spiffy (http://wiki.call-cc.org/egg/spiffy) and several web-related Chicken
eggs (like http-session (http://wiki.call-cc.org/egg/http-session) and
spiffy-request-vars (http://wiki.call-cc.org/egg/spiffy-request-vars)).

The sandbox (http://wiki.call-cc.org/egg/sandbox) egg provides a safe
evaluation context for basic Scheme expressions.

We're going to implement a very simple web-based Chicken REPL using a sandbox
environment for safe evaluation.

The idea is to have a web page with an input box. Users type the forms they
want to evaluate and submit them to the server. The server evaluates the
given forms in a sandbox environment and return the results.

Here's the commented code:

    (use html-tags awful sandbox)
    
    ;; Here we define the REPL page.  It uses the session to store the
    ;; sandboxed environment.  By default, the `main-page-path' parameter
    ;; value is "/".
    (define-session-page (main-page-path)
      (lambda ()
    
        ;; Create the sandbox environment (if it does not exist yet) and
        ;; store it in the user session.
        (unless ($session 'sandbox-env)
          ($session-set! 'sandbox-env
                         (make-safe-environment
                          parent: default-safe-environment
                          mutable: #t
                          extendable: #t)))
    
        ;; Here we set an ajax handler for the REPL expressions
        ;; submission.  When users change the REPL input widget (i.e., by
        ;; pressing ENTER), the contents of the text input field are
        ;; submitted and handled by the procedure given as the forth
        ;; argument to `ajax'.
        (ajax "eval" 'repl-input 'change
              (lambda ()
    
                ;; This binds the variable `repl-input' from the POST
                ;; method the the `repl-input' Scheme variable
                (let ((repl-input ($ 'repl-input)))
    
                  ;; We'd better handle exceptions when trying to
                  ;; evaluate the expressions given by users.
                  (handle-exceptions
                   exn
                   ;; If something goes wrong, we print the error message
                   ;; and the call chain.
                   (<pre> convert-to-entities?: #t
                          (with-output-to-string
                            (lambda ()
                              (print-error-message exn)
                              (print-call-chain))))
                   ;; Here we try to evaluate the given expression in the
                   ;; sandboxed environment stored in the user session. 
                   ;; The `repl-output' page div is updated with the result.
                   (<pre> convert-to-entities?: #t
                          (safe-eval
                           (with-input-from-string repl-input read)
                           fuel: 100
                           allocation-limit: 100
                           environment: ($session 'sandbox-env))))))
    
              ;; Here we pass the contents of the text input to the ajax
              ;; handler.  The default HTTP method used by `ajax' is POST.
              arguments: `((repl-input . "$('#repl-input').val()"))
    
              ;; The output of the ajax handler updates the `repl-output'
              ;; page div.
              target: "repl-output")
    
        ;; Here's what is displayed to users
        (++ (<h1> "Sandboxed Chicken web REPL")
            (<input> type: "text" id: "repl-input")
            (<div> id: "repl-output")))
    
      ;; This tells `define-session-page' to link the page to JQuery
      use-ajax: #t)

To run the code above you'll need to install awful and sandbox:

     $ chicken-install awful sandbox

Then (considering you save the code above in a file called
`web-sandbox.scm`), run:

     $ awful web-sandbox.scm

and access `http://localhost:8080`.

Here are some screenshots of the code above running on Firefox:
http://gazette.call-cc.org/img/10/web-sandbox.png

If you try something nasty, the sandbox will abort the evaluation and you'll
get an error message and the call chain:
http://gazette.call-cc.org/img/10/web-sandbox-loop.png

We can also compile the web application:

    $ csc -s web-sandbox.scm
    $ awful web-sandbox.so

That's awful!

== 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 --- ]

Best wishes.
Mario
-- 
http://parenteses.org/mario



reply via email to

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