CHICKEN for Racket programmers

Warning: This is very much a work in progress!

  1. CHICKEN for Racket programmers
    1. Running scripts
    2. Procedures
      1. Optional arguments
      2. Named parameters
    3. String manipulation
      1. Splitting strings
      2. Regular expressions

Running scripts

Racket:

#!/usr/bin/env racket

#lang racket

For Chicken, using env as shown above is not a viable solution because the Chicken Scheme interpreter (csi) requires the -s option in order to run in script mode rather than in REPL mode. And it seems as if, currently, only GNU env provides a way to run commands with additional arguments form a shebang line.

So, the most straightforward way to get your Chicken scripts to run is simply using the actual path to the Chicken Scheme interpreter on your system. This can easily be found by running command -v csi in a non-interactive POSIX-compatible shell:

$ sh -c 'command -v csi'

Running the shell non-interactively bypasses any existing shell command aliases, which is the desired behavior here.

On a Debian system, the above command returns /usr/bin/csi. On NetBSD, you get /usr/pkg/bin/csi. So, to create a runnable Chicken script on the latter, the first line in the file has to be this:

#!/usr/pkg/bin/csi -s

Should you need your Chicken scripts to be portable, there are also ways to achieve that without using env. See Writing portable scripts.

Procedures

Optional arguments

Named parameters

String manipulation

Splitting strings

Regular expressions