Chicken

Chicken is a Scheme Dialect that produces portable and efficient C and supports the R5RS and R7RS standards.

Resources

Books

Videos

Community

Installation

Debian/Ubuntu

apt install chicken-bin

Arch

pacman -S chicken

Nix

nix shell nixpkgs#chicken

Guix

guix shell -p chicken

REPL

You can enter the chicken REPL using the csi command. When you enter the REPL, you can enter the ,? command to learn about the available commands. This will display a list of special commands that you can use to debug your code.

Running scripts

You can use the csi command to run scripts by adding the -ss flag followed by the .scm file then optionally followed by the arguments that you would like to pass to this script.

csi -ss scripfile.scm <args>

Compiling

You can use the csc command to compile your code to an executable:

csc csc -o outputname inputfile.scm
# then you can run the executable
./outputname

Or you can compile to a shared library file that you can use within other programs:

csc -shared file.scm

Editor Configuration

Emacs

Chicken support requires some additional steps:

  1. Install the necessary support eggs.
chicken-install -s apropos chicken-doc

For Chicken 5, you’ll also need SRFI-18.

chicken-install -s srfi-18
  1. Update the Chicken documentation database.
cd `csi -p '(chicken-home)'`
curl http://3e8.org/pub/chicken-doc/chicken-doc-repo.tgz | sudo tar zx

With Chicken 5, this process has changed slightly:

cd `csi -e '(import (chicken platform)) (display (chicken-home))(newline)'`
curl https://3e8.org/pub/chicken-doc/chicken-doc-repo-5.tgz | sudo tar zx

You can use the provided init.el by running the command emacs -Q -l init.el to run emacs with the minimal configuration to get you started.

Geiser

(use-package geiser-chicken
  :ensure t)

Dependencies Management

Chicken can be extended by additional libraries called "eggs" that can be easily installed by the command chicken-install.

chicken-install EXTENSIONNAME

The default location where eggs are installed is usually /usr/local/lib/chicken/<VERSION>. You can change the location where you want eggs to be isntalled by running setting the environment variable CHICKEN_REPOSITORY:

export CHICKEN_REPOSITORY=~/myeggs/lib/chicken/<VERSION>

or if you want to install eggs somewhere other than the default or your environment variable, you can use

chicken-install -p ~/myeggs <package>

Project Management

Ecosystem