Friendly CHICKEN

If you're a CHICKEN beginner, you come from another language or a different scheme implementation, there are a few things you might be wondering about, when you're first exposed to CHICKEN. This little tutorial shall help you to lower the barriers and highlight some little pitfalls so that your time with CHICKEN is more fun from the very beginning.

For a general introduction to CHICKEN, see Getting started.

UTF-8

CHICKEN's string procedures generally operate on byte-strings. That means they are not aware of encodings such as UTF-8. The following csi transcript shows this:

CHICKEN
(c) 2008-2020, The CHICKEN Team
(c) 2000-2007, Felix L. Winkelmann
Version 5.2.0 (rev 317468e4)
linux-unix-gnu-x86-64 [ 64bit dload ptables ]

Type ,? for help.
#;1> (string-length "λ")
2
#;2>

As you see string-length on the string containing the unicode-character returns 2 rather than 1. To fix this you need to install and use the utf8 egg (chicken-install utf8).

See the transcript with utf8 loaded:

CHICKEN
(c) 2008-2020, The CHICKEN Team
(c) 2000-2007, Felix L. Winkelmann
Version 5.2.0 (rev 317468e4)
linux-unix-gnu-x86-64 [ 64bit dload ptables ]

Type ,? for help.
#;1> (import utf8)
; loading /home/mario/local/chicken-5.2.0/lib/chicken/11/utf8.import.so ...

Note: re-importing already imported identifier: string-length

Note: re-importing already imported identifier: string-ref

Note: re-importing already imported identifier: string-set!

Note: re-importing already imported identifier: make-string

Note: re-importing already imported identifier: string

Note: re-importing already imported identifier: substring

Note: re-importing already imported identifier: string->list

Note: re-importing already imported identifier: list->string

Note: re-importing already imported identifier: string-fill!

Note: re-importing already imported identifier: write-char

Note: re-importing already imported identifier: read-char

Note: re-importing already imported identifier: display

Note: re-importing already imported identifier: print

Note: re-importing already imported identifier: print*
; loading /home/mario/local/chicken-5.2.0/lib/chicken/11/utf8.so ...
; loading /home/mario/local/chicken-5.2.0/lib/chicken/11/regex.so ...
; loading /home/mario/local/chicken-5.2.0/lib/chicken/11/utf8-lolevel.so ...
#;2> (string-length "λ")
1

Nevermind the notes -- they are just an indication that procedures from the utf8 egg are redefining the procedures from the scheme module.

Load useful libraries and units in csi automatically

If you find yourself using these libraries alot you might want to have csi load them whenever you start it up. This can easily be done by adding them to your $HOME/.csirc.

A sample .csirc might look like this:

(import utf8 srfi-1 srfi-13)

Note that you have to install utf8, srfi-1 and srfi-13 via chicken-install.

Other useful eggs and units for real world tasks

There are some other units and eggs that you might find helpful to solve real world problems with CHICKEN. The following lists a few of them:

Eggs

Units

(You don't need to chicken-install these)

Happy Hacking

I hope this little guide helps you to start your CHICKEN journey without too many surprises. Have fun hacking ...