[ SDF Public Access UNIX System .. Est. 1987 ]

join welcome faq status members projects store tour gopher abuse dialup dsl minecraft social
tilde nihongo europa webmail gallery usermap teach irc tutorials software telnet ssh

Using Chicken on SDF

Chicken is a practical implementation of Scheme. Scheme is a programming language in the Lisp family.

Learn

To learn Scheme programming, check out a tutorial like Teach Yourself Scheme in Fixnum Days.

To learn about Chicken, check out the Chicken website, which includes a manual and a wiki.

Play Around

To play with Chicken, start the interactive interpreter by running csi. It should look like this:

$ csi

CHICKEN
(c)2008-2011 The Chicken Team
(c)2000-2007 Felix L. Winkelmann
Version 4.7.0 
netbsd-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
compiled 2011-08-24 on ol (NetBSD)

#;1> 

At the Chicken prompt, you can type in a Scheme program and hit Return to run your code.

#;1> (print "Hello, World")
Hello, World
#;2>

Install Eggs

The Chicken community produces third-party libraries called eggs. (If you're familiar with the Ruby programming language, eggs are like Ruby's gems.) As an example, let's install the readline egg. This will allow you to use in the Chicken interpreter the same editing and history commands you use in your shell. For example, hitting the Up key will enter your previous command.

Ideally, you could just run chicken-install readline and the egg would be installed. But if you do that, you'll get an error. Since you don't have administrator privileges on SDF, you can't install eggs to the default location (a system directory). You must install the eggs in your home directory, which requires you to do a little configuration beforehand. I'll show you how to do that.

I'll assume you're running Bash as your shell and that you want to keep Chicken-related files in ~/chicken. First create a directory for a Chicken repository:

mkdir -p ~/chicken/lib/chicken/6

Then install the repository:

chicken-install -init ~/chicken/lib/chicken/6

Then create some environment variables so Chicken will know to use your new repository for eggs, and will compile against SDF's system libraries when installing eggs:

export CHICKEN_INCLUDE_PATH=${HOME}/chicken/lib/chicken/6
export CHICKEN_REPOSITORY=${HOME}/chicken/lib/chicken/6
export CSC_OPTIONS="-I/usr/pkg/include -L/usr/pkg/lib -static-libs"

(You may also wish to put the above lines in a shell startup file, like ~/.bash_profile, so that the variables will be set every time you log in to SDF.)

Now you can install the readline egg:

chicken-install readline

If the install was successful, we can check whether everything's working. Start the Chicken interpreter with csi and run this Scheme program to load the readline egg:

(use readline)

Then run this program to use readline in this interpreter session:

(current-input-port (make-gnu-readline-port))

Now check if you have readline support in the interpreter. Run a trivial program like 42 and then hit the Up key and check if "42" gets entered at the prompt. If so, the readline egg is installed and working. You can put the first two Scheme programs (the ones that load the egg and make it work) into a ~/.csirc file and the interpreter will run those programs at the beginning of each session.


$Id: chicken.html,v 1.15 2011/08/29 06:43:41 ab9 Exp $


©1987-2065 SDF Public Access UNIX System, Inc. 501(c)(7)
(this page was generated using ksh, sed and awk)