You are looking at historical revision 8799 of this page. It may differ significantly from its current revision.

The following page is an introduction to Chicken intended to PHP programmers.

This is a work in progress, I will try to work on as frequently as possible (mostly on sunday). In the meantime, feel free to help me by expanding it, correcting (english is not my native language) and/or by commenting on what I have done so far.

Chicken is an implementation of the Scheme programming language which, in turn is a member of the Lisp family of languages. More information about this on the http://schemers.org/ website.

Syntax

Where PHP use the general syntax f(args, ...); , scheme use (f args...)

For example:

substr("abcdef", 0, 2);

is in Scheme:

(substring "abcdef" 0 2)

You will note that:

All scheme expressions use this format, including arithmetic.

The php expression:

3 + 5

Is in scheme:

(+ 3 5)

This is called prefix notation. It may take some time to get used to it but it had several advantages; mostly by avoiding any ambiguity in the operator precedences.

A more complex example can be:

3 + 5 - 12 * 2

Is represented in scheme as:

(- (+ 3 5)(* 12 2))

Variables

Like PHP, scheme does not type variables. If you assign $var to a string, it is a string. you re-assign it to 3, it become a number.

Booleans

TRUE, in scheme, is noted #t while FALSE is noted #f. Unlike PHP, all scheme values are considered to be true (#t) except #f itself, including zero (0), the empty string and others empty structures.

Numbers