source: project/chicken/branches/hygienic/manual/Basic mode of operation @ 11013

Last change on this file since 11013 was 11013, checked in by felix winkelmann, 13 years ago

removed require-for-syntax; fix in data-structures import lib

File size: 2.3 KB
1[[tags: manual]]
3== Basic mode of operation
5The compiler translates Scheme source code into fairly portable C that
6can be compiled and linked with most available C compilers. CHICKEN supports
7the generation of executables and libraries, linked either statically or
8dynamically. Compiled Scheme code can be loaded dynamically, or can be
9embedded in applications written in other languages. Separate compilation
10of modules is fully supported.
12The most portable way of creating separately linkable entities is
13supported by so-called ''unit''s.  A unit is a single
14compiled object module that contains a number of toplevel expressions that
15are executed either when the unit is the ''main'' unit or if the
16unit is ''used''.  To use a unit, the unit has to be ''declare''ed
17as used, like this:
19<enscript highlight=scheme>
20(declare (uses UNITNAME))
23The toplevel expressions of used units are executed in the order in
24which the units appear in the {{uses}} declaration. Units
25may be used multiple times and {{uses}} declarations may
26be circular (the unit is initialized at most once).  To compile a file
27as a unit, add a {{unit}} declaration:
29<enscript highlight=scheme>
30(declare (unit UNITNAME))
33When compiling different object modules, make sure to have one main
34unit. This unit is called initially and initializes all used units
35before executing its toplevel expressions. The main-unit has no
36{{unit}} declaration.
38Another method of using definitions in separate source files is to
39''include'' them. This simply inserts the code in a given file into
40the current file:
42<enscript highlight=scheme>
43(include "FILENAME")
46Macro definitions are only available when processed by {{include}} or
47{{import}}. Macro definitions in separate units are not available,
48since they are defined at compile time, i.e the time when that other
49unit was compiled (macros can optionally be available at runtime, see
50{{define-syntax}} in [[Non-standard macros and special forms|Substitution forms and macros]]).
52On platforms that support dynamic loading of compiled code (Windows, most ELF based
53systems like Linux or BSD, MacOS X, and others) code can be compiled into a shared object {{.dll}}, {{.so}}, {{.dylib}}) and loaded
54dynamically into a running application.
56Previous: [[The User's Manual]]
57Next: [[Using the compiler]]
Note: See TracBrowser for help on using the repository browser.