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

Porting CHICKEN 4 code to CHICKEN 5

This guide will take you by the hand and explain how to port code from CHICKEN 4 to CHICKEN 5. If your code is an egg, you might want to manually compile the source components at first before finishing up the egg itself.

If you prefer to first fix the egg's compilation infrastructure, scroll down to the section on egg (re-)packaging, then go back up and take care of your code afterwards.

Begin with the easy part: replacing module imports

When you have some CHICKEN 4 code to port to CHICKEN 5, the best way to get started is by first installing all the eggs you know are needed.

Then, in your code, replace every use and require-extension with import, and then compile the code.

This should give lots of errors about unknown modules. If you are using any of the following modules from CHICKEN 4 core, these have moved to an egg so you should install the corresponding egg before proceeding:

Some other procedures have also been moved into eggs, but we'll deal with those later. Installing these "large" eggs will take care of fixing the bulk of your import issues.

Now, after you've installed the required eggs you can recompile, and you'll typically still get errors about nonexisting core modules (like "chicken", "extras", "posix" and so on). The easiest way to get rid of this is to simply remove those modules from your import forms, and then retrying the compilation.

If your code is wrapped in a module, eventually, you'll be left only with errors about missing imports, and cascade-style errors caused by missing macros (these can be very misleading, so pay attention!). For example:

Fixing more missing procedures by installing eggs

After you've fixed your core imports and installed the SRFI eggs, you might notice some problems if you're using particular procedures from old core modules that are no longer available. Some of those have been moved into separate eggs. If this is the case with your code, take a look through the list below.

Some procedures from the "utils" module have been moved into several eggs:

Some procedures from "lolevel" have been moved into an object-evict egg:

The following procedures from data-structures have been moved to the queue egg:

And the binary-search procedure from data-structures has also been put into its own egg.

From the posix module, memory mapped I/O has been moved into its own memory-mapped-files egg. Specifically, these procedures have been moved there:

Also removed from posix are the group information procedures, which have been moved to the posix-groups egg. These are the following:

Lastly, a few macros from chicken were moved into the miscmacros egg:

Re-packaging eggs

If your code is an egg, you'll have to rewrite your setup file into the new "declarative" format. There's a /man/5/Extensions#creating-eggs|short description on how to create eggs for CHICKEN 5 in the manual, as well as a complete reference on the new file format.

Basically, the new way to make an egg involves writing a .egg file. This looks a lot like the old .meta file, with the author, name, license and dependency declarations. Added to this are "components", which make up the egg's sources.