- Chicken (Scheme implementation)
-
Chicken Scheme Original author(s) Felix Winkelmann Developer(s) The Chicken Team Initial release July 20, 2000[1] Stable release 4.7.0 / May 25, 2011 Development status Active Written in Scheme and C Operating system Cross-platform Type Programming language License BSD License Website call-cc.org Standard(s) R5RS (mostly) Chicken is a compiler and interpreter for the Scheme programming language that compiles Scheme code to standard C. It is mostly R5RS compliant and offers many extensions to the standard. Chicken is free software available under the BSD license.
Contents
Focus
Chicken's focus is immediately clear from its tagline: "A practical and portable Scheme system".
Much like Gauche, Chicken's main focus is the practical application of Scheme for writing "real-world" software. Scheme is well-known for its use in computer science curricula and programming language experimentation, but it hasn't seen much use in business and industry.[2] Chicken's community has produced a large set of libraries for performing a variety of tasks. The Chicken wiki (the software running it is also a Chicken program) also contains a list of software that people have written in Chicken.
Chicken's other goal is to be portable. By compiling to portable C (like Gambit and Bigloo), programs written in Chicken can be compiled for common popular platforms like Linux, Mac OS X and other Unix-like systems as well as Windows and Haiku.[3] It also has built-in support for cross-compilation of programs and extensions,[4] which allows it to be used on various embedded platforms.
Design
Like many Scheme compilers, Chicken uses standard C as an intermediate language. A Scheme program is translated into C by the Chicken compiler, and then a C compiler translates the C program into machine code for the target architecture, producing an executable program. The universal availability of C makes it ideal for this purpose.
Chicken's design was inspired by a 1994 paper[5] by Henry Baker that outlined an innovative strategy for Scheme compilation into C. A scheme program is compiled into C functions. These C functions never reach the return statement; instead, they call a new continuation when complete. These continuations are C functions themselves and are passed on as extra arguments to other C functions. They are calculated by the compiler.
So far, this is the essence of continuation-passing style. Baker's novel idea is to use the C stack for the Scheme heap. Hence, normal C stack operations such as automatic variable creation, variable-sized array allocation, and so on can be used. When the stack fills up (that is, the stack pointer reaches the top of the stack), a garbage collection can be initiated. The design used is a copying garbage collector originally devised by C.J. Cheney, which copies all live continuations and other live objects to the heap.[6] Despite this, the C code does not copy C stack frames, only Scheme objects, so it does not require knowledge of the C implementation.
In full, the Scheme heap consists of the C stack as the nursery together with the two heaps required by the generational garbage collector. This approach gives the speed of the C stack for many operations, and it allows the use of continuations as simple calls to C functions. Further, Baker's solution guarantees asymptotic tail recursive behavior, as required by the Scheme language standard. The implementation in the Chicken scheme compiler is even asymptotically safe for space.
Limitations and deviations from the standard
Chicken Scheme is mostly R5RS-compliant.
There is currently a guaranteed maximum of 120 arguments to a procedure. On common platforms, up to 2048 arguments are supported.
Add-on software
Chicken has a large repository of additional libraries and programs called "eggs". This eggs system is quite similar to RubyGems. It too does not integrate with the packaging system of the user's operating system. SWIG also supports Chicken.
See also
References
- ^ Felix Winkelmann, "Announcing the CHICKEN Scheme-to-C compiler". http://groups.google.com/group/comp.lang.scheme/msg/edfb2da16fd89fae., comp.lang.scheme
- ^ "Scheme FAQ". http://community.schemewiki.org/?scheme-faq-general., section "what is Scheme used for?"
- ^ "Portability". http://wiki.call-cc.org/portability. page on the Chicken wiki
- ^ "Cross development". http://wiki.call-cc.org/man/4/Cross%20development. - a section from the Chicken manual
- ^ Baker, Henry "CONS Should Not CONS Its Arguments, Part II: Cheney on the M.T.A.". http://home.pipeline.com/~hbaker1/CheneyMTA.html.
- ^ Cheney, C.J. "A Nonrecursive List Compacting Algorithm". CACM 13,11 (Nov. 1970), 677-678.
External links
Categories:- Scheme compilers
- Scheme interpreters
- Scheme implementations
Wikimedia Foundation. 2010.