This file is indexed.

/usr/share/doc/chicken-bin/manual-html/faq.html is in chicken-bin 4.11.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="manual.css" type="text/css" /></head>
<title>Chicken &raquo; faq</title>
<meta name="viewport" content="initial-scale=1" /></html>
<body>
<div id="body">
<div id="main">
<div id="toc">
<h2 class="toc">TOC &raquo;</h2>
<ul class="toc">
<li><a href="#sec:FAQ">FAQ</a>
<ul>
<li><a href="#sec:General_">General </a>
<ul>
<li><a href="#sec:Why_yet_another_Scheme_implementation.3f">Why yet another Scheme implementation?</a></li>
<li><a href="#sec:What_should_I_do_if_I_find_a_bug.3f">What should I do if I find a bug?</a></li></ul></li>
<li><a href="#sec:Specific">Specific</a>
<ul>
<li><a href="#sec:Why_are_values_defined_with_define-foreign-variable_or_define-constant_or_define-inline_not_seen_outside_of_the_containing_source_file.3f">Why are values defined with <tt>define-foreign-variable</tt> or <tt>define-constant</tt> or <tt>define-inline</tt> not seen outside of the containing source file?</a></li>
<li><a href="#sec:How_does_cond-expand_know_which_features_are_registered_in_used_units.3f">How does <tt>cond-expand</tt> know which features are registered in used units?</a></li>
<li><a href="#sec:Why_are_constants_defined_by_define-constant_not_honoured_in_case_constructs.3f">Why are constants defined by <tt>define-constant</tt> not honoured in <tt>case</tt> constructs?</a></li>
<li><a href="#sec:How_can_I_enable_case_sensitive_reading.2fwriting_in_user_code.3f">How can I enable case sensitive reading/writing in user code?</a></li>
<li><a href="#sec:Why_doesn.27t_CHICKEN_support_the_full_numeric_tower_by_default.3f">Why doesn't CHICKEN support the full numeric tower by default?</a></li>
<li><a href="#sec:Does_CHICKEN_support_native_threads.3f">Does CHICKEN support native threads?</a></li>
<li><a href="#sec:Does_CHICKEN_support_Unicode_strings.3f">Does CHICKEN support Unicode strings?</a></li></ul></li>
<li><a href="#sec:Why_are_.60dynamic-wind.27_thunks_not_executed_when_a_SRFI-18_thread_signals_an_error.3f">Why are `dynamic-wind' thunks not executed when a SRFI-18 thread signals an error?</a></li>
<li><a href="#sec:Platform_specific">Platform specific</a>
<ul>
<li><a href="#sec:How_do_I_generate_a_DLL_under_MS_Windows_.28tm.29_.3f">How do I generate a DLL under MS Windows (tm) ?</a></li>
<li><a href="#sec:How_do_I_generate_a_GUI_application_under_Windows.28tm.29.3f">How do I generate a GUI application under Windows(tm)?</a></li>
<li><a href="#sec:Compiling_very_large_files_under_Windows_with_the_Microsoft_C_compiler_fails_with_a_message_indicating_insufficient_heap_space.2e">Compiling very large files under Windows with the Microsoft C compiler fails with a message indicating insufficient heap space.</a></li>
<li><a href="#sec:When_I_run_csi_inside_an_emacs_buffer_under_Windows.2c_nothing_happens.2e">When I run <tt>csi</tt> inside an emacs buffer under Windows, nothing happens.</a></li>
<li><a href="#sec:On_Windows.2c_csc.2eexe_seems_to_be_doing_something_wrong.2e">On Windows, <tt>csc.exe</tt> seems to be doing something wrong.</a></li>
<li><a href="#sec:On_Windows_source_and.2for_output_filenames_with_embedded_whitespace_are_not_found.2e">On Windows source and/or output filenames with embedded whitespace are not found.</a></li></ul></li>
<li><a href="#sec:Customization">Customization</a>
<ul>
<li><a href="#sec:How_do_I_run_custom_startup_code_before_the_runtime-system_is_invoked.3f">How do I run custom startup code before the runtime-system is invoked?</a></li>
<li><a href="#sec:How_can_I_add_compiled_user_passes.3f">How can I add compiled user passes?</a></li></ul></li>
<li><a href="#sec:Macros">Macros</a>
<ul>
<li><a href="#sec:Where_is_define-macro.3f">Where is <tt>define-macro</tt>?</a></li>
<li><a href="#sec:Why_are_low-level_macros_defined_with_define-syntax_complaining_about_unbound_variables.3f">Why are low-level macros defined with <tt>define-syntax</tt> complaining about unbound variables?</a></li>
<li><a href="#sec:Why_isn.27t_load_properly_loading_my_library_of_macros.3f">Why isn't <tt>load</tt> properly loading my library of macros?</a></li></ul></li>
<li><a href="#sec:Warnings_and_errors">Warnings and errors</a>
<ul>
<li><a href="#sec:Why_does_my_program_crash_when_I_use_callback_functions_.28from_Scheme_to_C_and_back_to_Scheme_again.29.3f">Why does my program crash when I use callback functions (from Scheme to C and back to Scheme again)?</a></li>
<li><a href="#sec:Why_does_the_linker_complain_about_a_missing_function__C_.2e.2e.2e_toplevel.3f">Why does the linker complain about a missing function <tt>_C_..._toplevel</tt>?</a></li>
<li><a href="#sec:Why_does_the_linker_complain_about_a_missing_function__C_toplevel.3f">Why does the linker complain about a missing function <tt>_C_toplevel</tt>?</a></li>
<li><a href="#sec:Why_does_my_program_crash_when_I_compile_a_file_with_-unsafe_or_unsafe_declarations.3f">Why does my program crash when I compile a file with <tt>-unsafe</tt> or unsafe declarations?</a></li>
<li><a href="#sec:Why_don.27t_toplevel-continuations_captured_in_interpreted_code_work.3f">Why don't toplevel-continuations captured in interpreted code work?</a></li>
<li><a href="#sec:Why_does_define-reader-ctor_not_work_in_my_compiled_program.3f">Why does <tt>define-reader-ctor</tt> not work in my compiled program?</a></li>
<li><a href="#sec:Why_do_built-in_units.2c_such_as_srfi-1.2c_srfi-18.2c_and_posix_fail_to_load.3f">Why do built-in units, such as srfi-1, srfi-18, and posix fail to load?</a></li>
<li><a href="#sec:How_can_I_increase_the_size_of_the_trace_shown_when_runtime_errors_are_detected.3f">How can I increase the size of the trace shown when runtime errors are detected?</a></li></ul></li>
<li><a href="#sec:Optimizations">Optimizations</a>
<ul>
<li><a href="#sec:How_can_I_obtain_smaller_executables.3f">How can I obtain smaller executables?</a></li>
<li><a href="#sec:How_can_I_obtain_faster_executables.3f">How can I obtain faster executables?</a></li>
<li><a href="#sec:Which_non-standard_procedures_are_treated_specially_when_the_extended-bindings_or_usual-integrations_declaration_or_compiler_option_is_used.3f">Which non-standard procedures are treated specially when the <tt>extended-bindings</tt> or <tt>usual-integrations</tt> declaration or compiler option is used?</a></li>
<li><a href="#sec:What.27s_the_difference_betweem_.22block.22_and_.22local.22_mode.3f">What's the difference betweem &quot;block&quot; and &quot;local&quot; mode?</a></li>
<li><a href="#sec:Can_I_load_compiled_code_at_runtime.3f">Can I load compiled code at runtime?</a></li>
<li><a href="#sec:Why_is_my_program_which_uses_regular_expressions_so_slow.3f">Why is my program which uses regular expressions so slow?</a></li></ul></li>
<li><a href="#sec:Garbage_collection">Garbage collection</a>
<ul>
<li><a href="#sec:Why_does_a_loop_that_doesn.27t_cons_still_trigger_garbage_collections.3f">Why does a loop that doesn't <tt>cons</tt> still trigger garbage collections?</a></li>
<li><a href="#sec:Why_do_finalizers_not_seem_to_work_in_simple_cases_in_the_interpeter.3f">Why do finalizers not seem to work in simple cases in the interpeter?</a></li></ul></li>
<li><a href="#sec:Interpreter">Interpreter</a>
<ul>
<li><a href="#sec:Does_CSI_support_history_and_autocompletion.3f">Does CSI support history and autocompletion?</a></li>
<li><a href="#sec:Does_code_loaded_with_load_run_compiled_or_interpreted.3f">Does code loaded with <tt>load</tt> run compiled or interpreted?</a></li>
<li><a href="#sec:How_do_I_use_extended_.28non-standard.29_syntax_in_evaluated_code_at_run-time.3f">How do I use extended (non-standard) syntax in evaluated code at run-time?</a></li></ul></li>
<li><a href="#sec:Extensions_">Extensions </a>
<ul>
<li><a href="#sec:Where_is_.22chicken-setup.22_.3f">Where is &quot;chicken-setup&quot; ?</a></li>
<li><a href="#sec:How_can_I_install_CHICKEN_eggs_to_a_non-default_location.3f">How can I install CHICKEN eggs to a non-default location?</a></li>
<li><a href="#sec:Can_I_install_chicken_eggs_as_a_non-root_user.3f">Can I install chicken eggs as a non-root user?</a></li>
<li><a href="#sec:Why_does_downloading_an_extension_via_chicken-install_fail_on_Windows_Vista.3f">Why does downloading an extension via <tt>chicken-install</tt> fail on Windows Vista?</a></li></ul></li></ul></li></ul></div><h2 id="sec:FAQ"><a href="#sec:FAQ">FAQ</a></h2><p>This is the list of Frequently Asked Questions about CHICKEN Scheme. If you have a question not answered here, feel free to post to the chicken-users mailing list; if you consider your question general enough, feel free to add it to this list.</p><h3 id="sec:General_"><a href="#sec:General_">General </a></h3><h4 id="sec:Why_yet_another_Scheme_implementation.3f"><a href="#sec:Why_yet_another_Scheme_implementation.3f">Why yet another Scheme implementation?</a></h4><p>Since Scheme is a relatively simple language, a large number of implementations exist and each has its specific advantages and disadvantages. Some are fast, some provide a rich programming environment. Some are free, others are tailored to specific domains, and so on. The reasons for the existence of CHICKEN are:</p><ul><li>CHICKEN is portable because it generates C code that runs on a large number of platforms.</li>
<li>CHICKEN is extensible, since its code generation scheme and runtime system/garbage collector fits neatly into a C environment.</li>
<li>CHICKEN is free and can be freely distributed, including its source code.</li>
<li>CHICKEN offers better performance than nearly all interpreter based implementations, but still provides full Scheme semantics.</li>
<li>As far as we know, CHICKEN is the first implementation of Scheme that uses Henry Baker's <a href="http://home.pipeline.com/~hbaker1/CheneyMTA.html">Cheney on the M.T.A</a> concept.</li>
</ul>
<h4 id="sec:What_should_I_do_if_I_find_a_bug.3f"><a href="#sec:What_should_I_do_if_I_find_a_bug.3f">What should I do if I find a bug?</a></h4><p>Fill a ticket at <a href="http://bugs.call-cc.org">bugs.call-cc.org</a> with some hints about the problem, like version/build of the compiler, platform, system configuration, code that causes the bug, etc.</p><h3 id="sec:Specific"><a href="#sec:Specific">Specific</a></h3><h4 id="sec:Why_are_values_defined_with_define-foreign-variable_or_define-constant_or_define-inline_not_seen_outside_of_the_containing_source_file.3f"><a href="#sec:Why_are_values_defined_with_define-foreign-variable_or_define-constant_or_define-inline_not_seen_outside_of_the_containing_source_file.3f">Why are values defined with <tt>define-foreign-variable</tt> or <tt>define-constant</tt> or <tt>define-inline</tt> not seen outside of the containing source file?</a></h4><p>Accesses to foreign variables are translated directly into C constructs that access the variable, so the Scheme name given to that variable does only exist during compile-time. The same goes for constant- and inline-definitions: The name is only there to tell the compiler that this reference is to be replaced with the actual value.</p><h4 id="sec:How_does_cond-expand_know_which_features_are_registered_in_used_units.3f"><a href="#sec:How_does_cond-expand_know_which_features_are_registered_in_used_units.3f">How does <tt>cond-expand</tt> know which features are registered in used units?</a></h4><p>Each unit used via <tt>(declare (uses ...))</tt> is registered as a feature and so a symbol with the unit-name can be tested by <tt>cond-expand</tt> during macro-expansion-time. Features registered using the <tt>register-feature!</tt> procedure are only available during run-time of the compiled file. You can use the <tt>eval-when</tt> form to register features at compile time.</p><h4 id="sec:Why_are_constants_defined_by_define-constant_not_honoured_in_case_constructs.3f"><a href="#sec:Why_are_constants_defined_by_define-constant_not_honoured_in_case_constructs.3f">Why are constants defined by <tt>define-constant</tt> not honoured in <tt>case</tt> constructs?</a></h4><p><tt>case</tt> expands into a cascaded <tt>if</tt> expression, where the first item in each arm is treated as a quoted list. So the <tt>case</tt> macro can not infer whether a symbol is to be treated as a constant-name (defined via <tt>define-constant</tt>) or a literal symbol.</p><h4 id="sec:How_can_I_enable_case_sensitive_reading.2fwriting_in_user_code.3f"><a href="#sec:How_can_I_enable_case_sensitive_reading.2fwriting_in_user_code.3f">How can I enable case sensitive reading/writing in user code?</a></h4><p>To enable the <tt>read</tt> procedure to read symbols and identifiers case sensitive, you can set the parameter <tt>case-sensitivity</tt> to <tt>#t</tt>.</p><h4 id="sec:Why_doesn.27t_CHICKEN_support_the_full_numeric_tower_by_default.3f"><a href="#sec:Why_doesn.27t_CHICKEN_support_the_full_numeric_tower_by_default.3f">Why doesn't CHICKEN support the full numeric tower by default?</a></h4><p>The short answer is to use the <a href="http://wiki.call-cc.org/egg/numbers">numbers</a> egg:</p>
<pre class="highlight colorize">% chicken-install numbers
% csi -q
#<span class="comment">;1&gt; (use numbers)</span></pre><p>The long answer:</p><p>There are a number of reasons for this:</p><p>- For most applications of Scheme fixnums (exact word-sized integers) and flonums (64-bit floating-point numbers) are more than sufficient;</p><p>- Interfacing to C is simpler;</p><p>- Dispatching of arithmetic operations is more efficient.</p><h4 id="sec:Does_CHICKEN_support_native_threads.3f"><a href="#sec:Does_CHICKEN_support_native_threads.3f">Does CHICKEN support native threads?</a></h4><p>Native threads are not supported for two reasons. One, the runtime system is not reentrant.  Two, concurrency implemented properly would require mandatory locking of every object that could be potentially shared between two threads. The garbage-collection algorithm would then become much more complex and inefficient, since the location of every object has to be accessed via a thread synchronization protocol. Such a design would make native threads in CHICKEN essentially equivalent to Unix processes and shared memory.</p><p>For a different approach to concurrency, please see the <a href="http://wiki.call-cc.org/egg/mpi">mpi</a> or <a href="http://wiki.call-cc.org/egg/concurrent-native-callbacks">concurrent-native-callbacks</a> egg.</p><p><a href="http://www.stylewarning.com/blog/about">Robert Smith</a> has put <a href="http://www.stylewarning.com/blog/bounties">a bounty</a> on a release-quality implementation of native threads.</p><h4 id="sec:Does_CHICKEN_support_Unicode_strings.3f"><a href="#sec:Does_CHICKEN_support_Unicode_strings.3f">Does CHICKEN support Unicode strings?</a></h4><p>The system does not directly support Unicode, but there is an extension for UTF-8 strings: <a href="http://wiki.call-cc.org/egg/utf8">utf8</a>.</p><h3 id="sec:Why_are_.60dynamic-wind.27_thunks_not_executed_when_a_SRFI-18_thread_signals_an_error.3f"><a href="#sec:Why_are_.60dynamic-wind.27_thunks_not_executed_when_a_SRFI-18_thread_signals_an_error.3f">Why are `dynamic-wind' thunks not executed when a SRFI-18 thread signals an error?</a></h3><p>Here is what Marc Feeley, the author of <a href="http://srfi.schemers.org/srfi-18">SRFI-18</a> has to say about this subject:</p><pre>   &gt;No the default exception handler shouldn't invoke the after
   &gt; thunks of the current continuation.  That's because the
   &gt; exception handler doesn't &quot;continue&quot; at the initial
   &gt; continuation of that thread.  Here are the relevant words of
   &gt; SRFI 18:
   
   &gt;
   &gt;  Moreover, in this dynamic environment the exception handler
   &gt;  is bound to the &quot;initial exception handler&quot; which is a unary
   &gt;  procedure which causes the (then) current thread to store in
   &gt;  its end-exception field an &quot;uncaught exception&quot; object whose
   &gt;  &quot;reason&quot; is the argument of the handler, abandon all mutexes
   &gt;  it owns, and finally terminate.
   &gt;
   
   &gt;The rationale is that, when an uncaught exception occurs in a
   &gt;thread the thread is in bad shape and things have gone
   &gt;sufficiently wrong that there is no universally acceptable way to
   &gt;continue execution.  Executing after thunks could require a
   &gt;whole lot of processing that the thread is not in a shape to do.
   &gt;So the safe thing is to terminate the thread.  If the programmer
   &gt;knows how to recover from an exception, then he can capture the
   &gt;continuation early on, and install an exception handler which
   &gt;invokes the continuation.  When the continuation is invoked the
   &gt;after thunks will execute.</pre><h3 id="sec:Platform_specific"><a href="#sec:Platform_specific">Platform specific</a></h3><h4 id="sec:How_do_I_generate_a_DLL_under_MS_Windows_.28tm.29_.3f"><a href="#sec:How_do_I_generate_a_DLL_under_MS_Windows_.28tm.29_.3f">How do I generate a DLL under MS Windows (tm) ?</a></h4><p>Use <tt>csc</tt> in combination with the <tt>-dll</tt> option:</p><p><tt>C:\&gt; csc foo.scm -dll</tt></p><h4 id="sec:How_do_I_generate_a_GUI_application_under_Windows.28tm.29.3f"><a href="#sec:How_do_I_generate_a_GUI_application_under_Windows.28tm.29.3f">How do I generate a GUI application under Windows(tm)?</a></h4><p>Invoke <tt>csc</tt> with the <tt>-gui</tt> option.  In GUI-mode, the runtime system displays error messages in a message box and does some rudimentary command-line parsing.</p><h4 id="sec:Compiling_very_large_files_under_Windows_with_the_Microsoft_C_compiler_fails_with_a_message_indicating_insufficient_heap_space.2e"><a href="#sec:Compiling_very_large_files_under_Windows_with_the_Microsoft_C_compiler_fails_with_a_message_indicating_insufficient_heap_space.2e">Compiling very large files under Windows with the Microsoft C compiler fails with a message indicating insufficient heap space.</a></h4><p>It seems that the Microsoft C compiler can only handle files up to a certain size, and it doesn't utilize virtual memory as well as the GNU C compiler, for example. Try closing running applications. If that fails, try to break up the Scheme code into several library units.</p><h4 id="sec:When_I_run_csi_inside_an_emacs_buffer_under_Windows.2c_nothing_happens.2e"><a href="#sec:When_I_run_csi_inside_an_emacs_buffer_under_Windows.2c_nothing_happens.2e">When I run <tt>csi</tt> inside an emacs buffer under Windows, nothing happens.</a></h4><p>Invoke <tt>csi</tt> with the <tt>-:c</tt> runtime option. Under Windows the interpreter thinks it is not running under control of a terminal and doesn't print the prompt and does not flush the output stream properly.</p><h4 id="sec:On_Windows.2c_csc.2eexe_seems_to_be_doing_something_wrong.2e"><a href="#sec:On_Windows.2c_csc.2eexe_seems_to_be_doing_something_wrong.2e">On Windows, <tt>csc.exe</tt> seems to be doing something wrong.</a></h4><p>The Windows development tools include a C# compiler with the same name. Either invoke <tt>csc.exe</tt> with a full pathname, or put the directory where you installed CHICKEN in front of the MS development tool path in the <tt>PATH</tt> environment variable.</p><h4 id="sec:On_Windows_source_and.2for_output_filenames_with_embedded_whitespace_are_not_found.2e"><a href="#sec:On_Windows_source_and.2for_output_filenames_with_embedded_whitespace_are_not_found.2e">On Windows source and/or output filenames with embedded whitespace are not found.</a></h4><p>There is no current workaround. Do not use filenames with embedded whitespace for code. However, command names with embedded whitespace will work correctly.</p><h3 id="sec:Customization"><a href="#sec:Customization">Customization</a></h3><h4 id="sec:How_do_I_run_custom_startup_code_before_the_runtime-system_is_invoked.3f"><a href="#sec:How_do_I_run_custom_startup_code_before_the_runtime-system_is_invoked.3f">How do I run custom startup code before the runtime-system is invoked?</a></h4><p>When you invoke the C compiler for your translated Scheme source program, add the C compiler option <tt>-DC_EMBEDDED</tt>, or pass <tt>-embedded</tt> to the <tt>csc</tt> driver program, so no entry-point function will be generated (<tt>main()</tt>). When your are finished with your startup processing, invoke:</p>
<pre class="highlight colorize">CHICKEN_main<span class="paren1">(<span class="default">argc, argv, C_toplevel</span>)</span>;</pre><p>where <tt>C_toplevel</tt> is the entry-point into the compiled Scheme code. You should add the following  declarations at the head of your code:</p>
<pre class="highlight colorize"><span class="special">#include &quot;chicken.h&quot;
</span><span class="symbol">extern</span> <span class="symbol">void</span> C_toplevel<span class="paren1">(<span class="default">C_word,C_word,C_word</span>)</span> C_noret;</pre><h4 id="sec:How_can_I_add_compiled_user_passes.3f"><a href="#sec:How_can_I_add_compiled_user_passes.3f">How can I add compiled user passes?</a></h4><p>To add a compiled user pass instead of an interpreted one, create a library unit and recompile the main unit of the compiler (in the file <tt>chicken.scm</tt>) with an additional <tt>uses</tt> declaration. Then link all compiler modules and your (compiled) extension to create a new version of the compiler, like this (assuming all sources are in the current directory):</p>
<pre class="highlight colorize">  % cat userpass.scm
  <span class="comment">;;;; userpass.scm - My very own compiler pass
</span>
  <span class="paren1">(<span class="default">declare <span class="paren2">(<span class="default">unit userpass</span>)</span></span>)</span>

  <span class="comment">;; Perhaps more user passes/extensions are added:
</span>  <span class="paren1">(<span class="default"><i><span class="symbol">let</span></i> <span class="paren2">(<span class="default"><span class="paren3">[<span class="default">old <span class="paren4">(<span class="default">user-pass</span>)</span></span>]</span></span>)</span>
    <span class="paren2">(<span class="default">user-pass
      <span class="paren3">(<span class="default"><i><span class="symbol">lambda</span></i> <span class="paren4">(<span class="default">x</span>)</span>
        <span class="paren4">(<span class="default"><i><span class="symbol">let</span></i> <span class="paren5">(<span class="default"><span class="paren6">[<span class="default">x2 <span class="paren1">(<span class="default">do-something-with x</span>)</span></span>]</span></span>)</span>
	   <span class="paren5">(<span class="default"><i><span class="symbol">if</span></i> old
	       <span class="paren6">(<span class="default">old x2</span>)</span>
	       x2</span>)</span> </span>)</span> </span>)</span> </span>)</span> </span>)</span></pre><pre>% csc -c -x userpass.scm
% csc chicken.scm -c -o chicken-extended.o -uses userpass
% gcc chicken-extended.o support.o easyffi.o compiler.o optimizer.o batch-driver.o c-platform.o \
c-backend.o userpass.o `csc -ldflags -libs` -o chicken-extended</pre><p>On platforms that support it (Linux ELF, Solaris, Windows + VC++), compiled code can be loaded via <tt>-extend</tt> just like source files (see <tt>load</tt> in the User's Manual).</p><h3 id="sec:Macros"><a href="#sec:Macros">Macros</a></h3><h4 id="sec:Where_is_define-macro.3f"><a href="#sec:Where_is_define-macro.3f">Where is <tt>define-macro</tt>?</a></h4><p>With CHICKEN 4, the macro-expansion subsystem is now hygienic where old Lisp-style low-level macros are not available anymore. <tt>define-syntax</tt> can define hygienic macros using <tt>syntax-rules</tt> or low-level macros with user-controlled hygienic with <i>explicit renaming</i> macros. Translating old-style macros into ER-macros isn't that hard, see <a href="Macros.html">Macros</a> for more information.</p><h4 id="sec:Why_are_low-level_macros_defined_with_define-syntax_complaining_about_unbound_variables.3f"><a href="#sec:Why_are_low-level_macros_defined_with_define-syntax_complaining_about_unbound_variables.3f">Why are low-level macros defined with <tt>define-syntax</tt> complaining about unbound variables?</a></h4><p>Macro bodies that are defined and used in a compiled source-file are evaluated during compilation and so have no access to anything created with <tt>define</tt>. Use <tt>define-for-syntax</tt> instead.</p><h4 id="sec:Why_isn.27t_load_properly_loading_my_library_of_macros.3f"><a href="#sec:Why_isn.27t_load_properly_loading_my_library_of_macros.3f">Why isn't <tt>load</tt> properly loading my library of macros?</a></h4><p>During compile-time, macros are only available in the source file in which they are defined. Files included via <tt>include</tt> are considered part of the containing file.</p><h3 id="sec:Warnings_and_errors"><a href="#sec:Warnings_and_errors">Warnings and errors</a></h3><h4 id="sec:Why_does_my_program_crash_when_I_use_callback_functions_.28from_Scheme_to_C_and_back_to_Scheme_again.29.3f"><a href="#sec:Why_does_my_program_crash_when_I_use_callback_functions_.28from_Scheme_to_C_and_back_to_Scheme_again.29.3f">Why does my program crash when I use callback functions (from Scheme to C and back to Scheme again)?</a></h4><p>There are two reasons why code involving callbacks can crash out of no apparent reason:</p><ol><li>It is important to use <tt>foreign-safe-lambda/foreign-safe-lambda*</tt> for the C code that is to call back into Scheme. If this is not done than sooner or later the available stack space will be exhausted.</li>
<li>If the C code uses a large amount of stack storage, or if Scheme-to-C-to-Scheme calls are nested deeply, then the available nursery space on the stack will run low. To avoid this it might be advisable to run the compiled code with a larger nursery setting, i.e. run the code with <tt>-:s...</tt> and a larger value than the default (for example <tt>-:s300k</tt>), or use the <tt>-nursery</tt> compiler option.  Note that this can decrease runtime performance on some platforms.</li>
</ol>
<h4 id="sec:Why_does_the_linker_complain_about_a_missing_function__C_.2e.2e.2e_toplevel.3f"><a href="#sec:Why_does_the_linker_complain_about_a_missing_function__C_.2e.2e.2e_toplevel.3f">Why does the linker complain about a missing function <tt>_C_..._toplevel</tt>?</a></h4><p>This message indicates that your program uses a library-unit, but that the object-file or library was not supplied to the linker. If you have the unit <tt>foo</tt>, which is contained in <tt>foo.o</tt> than you have to supply it to the linker like this (assuming a GCC environment):</p><p><tt>% csc program.scm foo.o -o program</tt></p><h4 id="sec:Why_does_the_linker_complain_about_a_missing_function__C_toplevel.3f"><a href="#sec:Why_does_the_linker_complain_about_a_missing_function__C_toplevel.3f">Why does the linker complain about a missing function <tt>_C_toplevel</tt>?</a></h4><p>This means you have compiled a library unit as an application. When a unit-declaration (as in <tt>(declare (unit ...))</tt>) is given, then this file has a specially named toplevel entry procedure. Just remove the declaration, or compile this file to an object-module and link it to your application code.</p><h4 id="sec:Why_does_my_program_crash_when_I_compile_a_file_with_-unsafe_or_unsafe_declarations.3f"><a href="#sec:Why_does_my_program_crash_when_I_compile_a_file_with_-unsafe_or_unsafe_declarations.3f">Why does my program crash when I compile a file with <tt>-unsafe</tt> or unsafe declarations?</a></h4><p>The compiler option <tt>-unsafe</tt> or the declaration <tt>(declare (unsafe))</tt> disable certain safety-checks to improve performance, so code that would normally trigger an error will work unexpectedly or even crash the running application. It is advisable to develop and debug a program in safe mode (without unsafe declarations) and use this feature only if the application works properly.</p><h4 id="sec:Why_don.27t_toplevel-continuations_captured_in_interpreted_code_work.3f"><a href="#sec:Why_don.27t_toplevel-continuations_captured_in_interpreted_code_work.3f">Why don't toplevel-continuations captured in interpreted code work?</a></h4><p>Consider the following piece of code:</p>
<pre class="highlight colorize">  
<span class="paren1">(<span class="default"><i><span class="symbol">define</span></i> k <span class="paren2">(<span class="default">call-with-current-continuation <span class="paren3">(<span class="default"><i><span class="symbol">lambda</span></i> <span class="paren4">(<span class="default">k</span>)</span> k</span>)</span></span>)</span></span>)</span>
<span class="paren1">(<span class="default">k k</span>)</span></pre><p>When compiled, this will loop endlessly. But when interpreted, <tt>(k k)</tt> will return to the read-eval-print loop! This happens because the continuation captured will eventually read the next toplevel expression from the standard-input (or an input-file if loading from a file). At the moment <tt>k</tt> was defined, the next expression was <tt>(k k)</tt>. But when <tt>k</tt> is invoked, the next expression will be whatever follows after <tt>(k k)</tt>. In other words, invoking a captured continuation will not rewind the file-position of the input source. A solution is to wrap the whole code into a <tt>(begin ...)</tt> expression, so all toplevel expressions will be loaded together.</p><h4 id="sec:Why_does_define-reader-ctor_not_work_in_my_compiled_program.3f"><a href="#sec:Why_does_define-reader-ctor_not_work_in_my_compiled_program.3f">Why does <tt>define-reader-ctor</tt> not work in my compiled program?</a></h4><p>The following piece of code does not work as expected:</p>
<pre class="highlight colorize"> <span class="paren1">(<span class="default"><i><span class="symbol">eval-when</span></i> <span class="paren2">(<span class="default">compile</span>)</span>
 <span class="paren2">(<span class="default"><i><span class="symbol">define-reader-ctor</span></i> &#x27;integer-&gt;char integer-&gt;char</span>)</span> </span>)</span>
 <span class="paren1">(<span class="default">print #,<span class="paren2">(<span class="default">integer-&gt;char 33</span>)</span></span>)</span></pre><p>The problem is that the compiler reads the complete source-file before doing any processing on it, so the sharp-comma form is encountered before the reader-ctor is defined. A possible solution is to include the file containing the sharp-comma form, like this:</p>
<pre class="highlight colorize"> <span class="paren1">(<span class="default"><i><span class="symbol">eval-when</span></i> <span class="paren2">(<span class="default">compile</span>)</span>
 <span class="paren2">(<span class="default"><i><span class="symbol">define-reader-ctor</span></i> &#x27;integer-&gt;char integer-&gt;char</span>)</span> </span>)</span>
 
 <span class="paren1">(<span class="default">include <span class="string">&quot;other-file&quot;</span></span>)</span></pre>
<pre class="highlight colorize"> <span class="comment">;;; other-file.scm:
</span> <span class="paren1">(<span class="default">print #,<span class="paren2">(<span class="default">integer-&gt;char 33</span>)</span></span>)</span></pre><h4 id="sec:Why_do_built-in_units.2c_such_as_srfi-1.2c_srfi-18.2c_and_posix_fail_to_load.3f"><a href="#sec:Why_do_built-in_units.2c_such_as_srfi-1.2c_srfi-18.2c_and_posix_fail_to_load.3f">Why do built-in units, such as srfi-1, srfi-18, and posix fail to load?</a></h4><p>When you try to <tt>use</tt> a built-in unit such as <tt>srfi-18</tt>, you may get the following error:</p>
<pre class="highlight colorize"> #<span class="comment">;1&gt; (use srfi-18)
</span> <span class="comment">; loading library srfi-18 ...
</span> <span class="keyword">Error:</span> <span class="paren1">(<span class="default">load-library</span>)</span> unable to load library
 srfi-18
 <span class="string">&quot;dlopen(libchicken.dylib, 9): image not found&quot;</span>                <span class="comment">;; on a Mac
</span> <span class="string">&quot;libchicken.so: cannot open shared object file: No such file or directory&quot;</span>  <span class="comment">;; Linux</span></pre><p>Another symptom is that <tt>(require 'srfi-18)</tt> will silently fail.</p><p>This typically happens because the CHICKEN libraries have been installed in a non-standard location, such as your home directory.  The workaround is to explicitly tell the dynamic linker where to look for your libraries:</p><pre>export DYLD_LIBRARY_PATH=~/scheme/chicken/lib:$DYLD_LIBRARY_PATH ;; Mac
export LD_LIBRARY_PATH=~/scheme/chicken/lib:$LD_LIBRARY_PATH    ;; Linux</pre><h4 id="sec:How_can_I_increase_the_size_of_the_trace_shown_when_runtime_errors_are_detected.3f"><a href="#sec:How_can_I_increase_the_size_of_the_trace_shown_when_runtime_errors_are_detected.3f">How can I increase the size of the trace shown when runtime errors are detected?</a></h4><p>When a runtime error is detected, CHICKEN will print the last entries from the trace of functions called (unless your executable was compiled with the <tt>-no-trace</tt> option. By default, only 16 entries will be shown. To increase this number pass the <tt>-:aN</tt> parameter to your executable.</p><h3 id="sec:Optimizations"><a href="#sec:Optimizations">Optimizations</a></h3><h4 id="sec:How_can_I_obtain_smaller_executables.3f"><a href="#sec:How_can_I_obtain_smaller_executables.3f">How can I obtain smaller executables?</a></h4><p>If you don't need <tt>eval</tt> or the stuff in the <tt>extras</tt> library unit, you can just use the <tt>library</tt> unit:</p>
<pre class="highlight colorize">	<span class="paren1">(<span class="default">declare <span class="paren2">(<span class="default">uses library</span>)</span></span>)</span>
	<span class="paren1">(<span class="default">display <span class="string">&quot;Hello, world!</span><span class="string">\n</span><span class="string">&quot;</span></span>)</span></pre><p>(Don't forget to compile with the <tt>-explicit-use</tt> option) Compiled with Visual C++ this generates an executable of around 240 kilobytes. It is theoretically possible to compile something without the library, but a program would have to implement quite a lot of support code on its own.</p><h4 id="sec:How_can_I_obtain_faster_executables.3f"><a href="#sec:How_can_I_obtain_faster_executables.3f">How can I obtain faster executables?</a></h4><p>There are a number of declaration specifiers that should be used to speed up compiled files: declaring <tt>(standard-bindings)</tt> is mandatory, since this enables most optimizations. Even if some standard procedures should be redefined, you can list untouched bindings in the declaration. Declaring <tt>(extended-bindings)</tt> lets the compiler choose faster versions of certain internal library functions. This might give another speedup. You can also use the the <tt>usual-integrations</tt> declaration, which is identical to declaring <tt>standard-bindings</tt> and <tt>extended-bindings</tt> (note that <tt>usual-integrations</tt> is set by default). Declaring <tt>(block)</tt> tells the compiler that global procedures are not changed outside the current compilation unit, this gives the compiler some more opportunities for optimization. If no floating point arithmetic is required, then declaring <tt>(number-type fixnum)</tt> can give a big performance improvement, because the compiler can now inline most arithmetic operations. Declaring <tt>(unsafe)</tt> will switch off most safety checks. If threads are not used, you can declare <tt>(disable-interrupts)</tt>. You should always use maximum optimizations settings for your C compiler. Good GCC compiler options on Pentium (and compatible) hardware are: <tt>-Os -fomit-frame-pointer -fno-strict-aliasing</tt> Some programs are very sensitive to the setting of the nursery (the first heap-generation). You should experiment with different nursery settings (either by compiling with the <tt>-nursery</tt> option or by using the <tt>-:s...</tt> runtime option).</p><h4 id="sec:Which_non-standard_procedures_are_treated_specially_when_the_extended-bindings_or_usual-integrations_declaration_or_compiler_option_is_used.3f"><a href="#sec:Which_non-standard_procedures_are_treated_specially_when_the_extended-bindings_or_usual-integrations_declaration_or_compiler_option_is_used.3f">Which non-standard procedures are treated specially when the <tt>extended-bindings</tt> or <tt>usual-integrations</tt> declaration or compiler option is used?</a></h4><p>The following standard bindings are handled specially, depending on optimization options and compiler settings:</p><p><tt>*</tt> <tt>+</tt> <tt>-</tt> <tt>/</tt> <tt>&lt;=</tt> <tt>&lt;</tt> <tt>=</tt> <tt>&gt;=</tt> <tt>&gt;</tt> <tt>abs</tt> <tt>acos</tt> <tt>apply</tt> <tt>asin</tt> <tt>assoc</tt> <tt>assv</tt> <tt>atan</tt> <tt>boolean?</tt> <tt>c...r</tt> <tt>call-with-current-continuation</tt> <tt>call-with-values</tt> <tt>ceiling</tt> <tt>char-&gt;integer</tt> <tt>char-alphabetic?</tt> <tt>char-downcase</tt> <tt>char-lower-case?</tt> <tt>char-numeric?</tt> <tt>char-upcae</tt> <tt>char-upper-case?</tt> <tt>char-whitespace?</tt> <tt>char&lt;=?</tt> <tt>char&lt;?</tt> <tt>char=?</tt> <tt>char&gt;=?</tt> <tt>char&gt;?</tt> <tt>char?</tt> <tt>complex?</tt> <tt>cons</tt> <tt>cos</tt> <tt>current-input-port</tt> <tt>current-output-port</tt> <tt>eof-object?</tt> <tt>eq?</tt> <tt>equal?</tt> <tt>eqv?</tt> <tt>even?</tt> <tt>exact-&gt;inexact</tt> <tt>exact?</tt> <tt>exp</tt> <tt>floor</tt> <tt>for-each</tt> <tt>for-each</tt> <tt>gcd</tt> <tt>inexact-&gt;exact</tt> <tt>inexact?</tt> <tt>integer-&gt;char</tt> <tt>lcm</tt> <tt>length</tt> <tt>list-ref</tt> <tt>list-tail</tt> <tt>list?</tt> <tt>list</tt> <tt>log</tt> <tt>make-vector</tt> <tt>map</tt> <tt>member</tt> <tt>memq</tt> <tt>memv</tt> <tt>negative?</tt> <tt>not</tt> <tt>null?</tt> <tt>number-&gt;string</tt> <tt>number?</tt> <tt>odd?</tt> <tt>pair?</tt> <tt>positive?</tt> <tt>procedure?</tt> <tt>quotient</tt> <tt>rational?</tt> <tt>read-string</tt> <tt>real?</tt> <tt>remainder</tt> <tt>round</tt> <tt>set-car!</tt> <tt>set-cdr!</tt> <tt>sin</tt> <tt>sqrt</tt> <tt>string-&gt;number</tt> <tt>string-append</tt> <tt>string-ci=?</tt> <tt>string-length</tt> <tt>string-ref</tt> <tt>string-set!</tt> <tt>string=?</tt> <tt>string?</tt> <tt>string</tt> <tt>substring</tt> <tt>symbol?</tt> <tt>tan</tt> <tt>truncate</tt> <tt>values</tt> <tt>vector-length</tt> <tt>vector-ref</tt> <tt>vector-set!</tt> <tt>vector?</tt> <tt>vector</tt> <tt>write-char</tt> <tt>zero?</tt></p><p>The following extended bindings are handled specially:</p><p><tt>add1</tt> <tt>alist-cons</tt> <tt>any?</tt> <tt>arithmetic-shift</tt> <tt>atom?</tt> <tt>bit-set?</tt> <tt>bitwise-and</tt> <tt>bitwise-ior</tt> <tt>bitwise-not</tt> <tt>bitwise-xor</tt> <tt>blob-size</tt> <tt>block-ref</tt> <tt>block-set!</tt> <tt>call/cc</tt> <tt>current-error-port</tt> <tt>current-thread</tt> <tt>error</tt> <tt>f32vector-&gt;blob/shared</tt> <tt>f32vector-length</tt> <tt>f32vector-ref</tt> <tt>f64vector-&gt;blob/shared</tt> <tt>f64vector-length</tt> <tt>f64vector-ref</tt> <tt>finite?</tt> <tt>first</tt> <tt>fixnum?</tt> <tt>flonum?</tt> <tt>flush-output</tt> <tt>foldl</tt> <tt>foldr</tt> <tt>format</tt> <tt>fourth</tt> <tt>fp*</tt> <tt>fp+</tt> <tt>fp-</tt> <tt>fp/</tt> <tt>fp&lt;=</tt> <tt>fp&lt;</tt> <tt>fp=</tt> <tt>fp=</tt> <tt>fp&gt;=</tt> <tt>fp&gt;=</tt> <tt>fp&gt;</tt> <tt>fp&gt;</tt> <tt>fpabs</tt> <tt>fpacos</tt> <tt>fpasin</tt> <tt>fpatan2</tt> <tt>fpatan</tt> <tt>fpceiling</tt> <tt>fpcos</tt> <tt>fpexpt</tt> <tt>fpexp</tt> <tt>fpfloor</tt> <tt>fpinteger?</tt> <tt>fplog</tt> <tt>fpmax</tt> <tt>fpmin</tt> <tt>fpneg</tt> <tt>fprintf</tt> <tt>fpround</tt> <tt>fpsin</tt> <tt>fpsqrt</tt> <tt>fptan</tt> <tt>fptruncate</tt> <tt>fx*?</tt> <tt>fx*</tt> <tt>fx+?</tt> <tt>fx+</tt> <tt>fx-?</tt> <tt>fx-</tt> <tt>fx/?</tt> <tt>fx/</tt> <tt>fx=</tt> <tt>fx&gt;=</tt> <tt>fx&gt;</tt> <tt>fxand</tt> <tt>fxeven?</tt> <tt>fxior</tt> <tt>fxmax</tt> <tt>fxmin</tt> <tt>fxmod</tt> <tt>fxneg</tt> <tt>fxnot</tt> <tt>fxodd?</tt> <tt>fxshl</tt> <tt>fxshr</tt> <tt>fxxor</tt> <tt>hash-table-ref</tt> <tt>identity</tt> <tt>locative-&gt;object</tt> <tt>locative-ref</tt> <tt>locative-set!</tt> <tt>locative?</tt> <tt>make-record-instance</tt> <tt>not-pair?</tt> <tt>null-list?</tt> <tt>number-of-slots</tt> <tt>o</tt> <tt>pointer+</tt> <tt>pointer-&gt;object</tt> <tt>pointer-f32-ref</tt> <tt>pointer-f32-set!</tt> <tt>pointer-f64-ref</tt> <tt>pointer-f64-set!</tt> <tt>pointer-s16-ref</tt> <tt>pointer-s16-set!</tt> <tt>pointer-s32-ref</tt> <tt>pointer-s32-set!</tt> <tt>pointer-s8-ref</tt> <tt>pointer-s8-set!</tt> <tt>pointer-u16-ref</tt> <tt>pointer-u16-set!</tt> <tt>pointer-u32-ref</tt> <tt>pointer-u32-set!</tt> <tt>pointer-u8-ref</tt> <tt>pointer-u8-set!</tt> <tt>pointer=?</tt> <tt>print*</tt> <tt>printf</tt> <tt>print</tt> <tt>s16vector-&gt;blob/shared</tt> <tt>s16vector-length</tt> <tt>s16vector-ref</tt> <tt>s16vector-set!</tt> <tt>s32vector-&gt;blob/shared</tt> <tt>s32vector-length</tt> <tt>s32vector-ref</tt> <tt>s32vector-set!</tt> <tt>s8vector-&gt;blob/shared</tt> <tt>s8vector-length</tt> <tt>s8vector-ref</tt> <tt>s8vector-set!</tt> <tt>second</tt> <tt>signum</tt> <tt>sprintf</tt> <tt>sub1</tt> <tt>substring-ci=?</tt> <tt>substring-index-ci</tt> <tt>substring-index</tt> <tt>substring=?</tt> <tt>third</tt> <tt>thread-specific-set!</tt> <tt>thread-specific</tt> <tt>u16vector-&gt;blob/shared</tt> <tt>u16vector-length</tt> <tt>u16vector-ref</tt> <tt>u16vector-set!</tt> <tt>u32vector-&gt;blob/shared</tt> <tt>u32vector-length</tt> <tt>u32vector-ref</tt> <tt>u32vector-set!</tt> <tt>u8vector-&gt;blob/shared</tt> <tt>u8vector-length</tt> <tt>u8vector-ref</tt> <tt>u8vector-set!</tt> <tt>xcons</tt></p><h4 id="sec:What.27s_the_difference_betweem_.22block.22_and_.22local.22_mode.3f"><a href="#sec:What.27s_the_difference_betweem_.22block.22_and_.22local.22_mode.3f">What's the difference betweem &quot;block&quot; and &quot;local&quot; mode?</a></h4><p>In <tt>block</tt> mode, the compiler assumes that definitions in the current file are not visible from outside of the current compilation unit, so unused definitions can be removed and calls can be inlined. In <tt>local</tt> mode, definitions are not hidden, but the compiler assumes that they are not modified from other compilation units (or code evaluated at runtime), and thus allows inlining of them.</p><h4 id="sec:Can_I_load_compiled_code_at_runtime.3f"><a href="#sec:Can_I_load_compiled_code_at_runtime.3f">Can I load compiled code at runtime?</a></h4><p>Yes. You can load compiled at code at runtime with <tt>load</tt> just as well as you can load Scheme source code.  Compiled code will, of course, run faster.</p><p>To do this, pass to <tt>load</tt> a path for a shared object.  Use a form such as <tt>(load &quot;foo.so&quot;)</tt> and run <tt>csc -shared foo.scm</tt> to produce <tt>foo.so</tt> from <tt>foo.scm</tt> (at which point <tt>foo.scm</tt> will no longer be required).</p><p>If you have compiled code that contains a <tt>module</tt> definition, then executing the code will &quot;register&quot; the module to allow importing the bindings provided by the module into a running Scheme process. The information required to use a module is in this case embedded in the compiled code. Compiling another program that uses this (compiled) module is more difficult: the used module will not necessarily be loaded into the compiler, so the registration will not be executed. In this case the information about what bindings the compiled module exports must be separated from the actual code that executes at runtime. To make this possible, compiling a module can be done in such a manner that an &quot;import library&quot; is created. This is a file that contains the binding information of the module and we can use it to compile a file that refers to that module. An example can perhaps make this clearer:</p><pre> ;; my-module.scm
 
 (module my-module (...) ...)</pre><pre> ;; use-my-module.scm</pre><pre> (import my-module)
 ...</pre><p>Compile the module and generate an import library for the &quot;my-module&quot; module:</p><pre> % csc -s my-module.scm -emit-import-library my-module</pre><p>Compile the program that uses the module:</p><pre> % csc use-my-module.scm</pre><h4 id="sec:Why_is_my_program_which_uses_regular_expressions_so_slow.3f"><a href="#sec:Why_is_my_program_which_uses_regular_expressions_so_slow.3f">Why is my program which uses regular expressions so slow?</a></h4><p>The regular expression engine has recently been replaced by <a href="http://wiki.call-cc.org/users/alex shinn">alex shinn</a>'s excellent <tt>irregex</tt> library, which is fully implemented in Scheme. Precompiling regular expressions to internal forms is somewhat slower than with the old PCRE-based regex engine. It is advisable to use <tt>irregex</tt> to precompile regular expressions outside of time-critical loops and use them where performance matters.</p><h3 id="sec:Garbage_collection"><a href="#sec:Garbage_collection">Garbage collection</a></h3><h4 id="sec:Why_does_a_loop_that_doesn.27t_cons_still_trigger_garbage_collections.3f"><a href="#sec:Why_does_a_loop_that_doesn.27t_cons_still_trigger_garbage_collections.3f">Why does a loop that doesn't <tt>cons</tt> still trigger garbage collections?</a></h4><p>Under CHICKEN's implementation policy, tail recursion is achieved simply by avoiding returns from function calls. Since the programs are CPS converted, a continuous sequence of nested procedure calls is performed. At some stage the stack-space has to run out and the current procedure and its parameters (including the current continuation) are stored somewhere in the runtime system. Now a minor garbage collection occurs and rescues all live data from the stack (the first heap generation) and moves it into the the second heap generation. Then the stack is cleared (using a <tt>longjmp</tt>) and execution can continue from the saved state. With this method arbitrary recursion (in tail- or non-tail position) can happen, provided the application doesn't run out of heap-space. (The difference between a tail- and a non-tail call is that the tail-call has no live data after it invokes its continuation - and so the amount of heap-space needed stays constant)</p><h4 id="sec:Why_do_finalizers_not_seem_to_work_in_simple_cases_in_the_interpeter.3f"><a href="#sec:Why_do_finalizers_not_seem_to_work_in_simple_cases_in_the_interpeter.3f">Why do finalizers not seem to work in simple cases in the interpeter?</a></h4><p>Consider the following interaction in CSI:</p><pre>#;1&gt; (define x '(1 2 3))
#;2&gt; (define (yammer x) (print x &quot; is dead&quot;))
#;3&gt; (set-finalizer! x yammer)
(1 2 3)
#;4&gt; (gc #t)
157812
#;5&gt; (define x #f)
#;6&gt; (gc #t)
157812
#;7&gt;</pre><p>While you might expect objects to be reclaimed and &quot;<i>(1 2 3) is dead</i>&quot; printed, it won't happen: the literal list gets held in the interpreter history, because it is the result value of the set-finalizer! call. Running this in a normal program will work fine.</p><p>When testing finalizers from the interpreter, you might want to define a trivial macro such as</p><pre>(define-syntax v
  (syntax-rules ()
    ((_ x) (begin (print x) (void)))))</pre><p>and wrap calls to <tt>set-finalizer!</tt> in it.</p><h3 id="sec:Interpreter"><a href="#sec:Interpreter">Interpreter</a></h3><h4 id="sec:Does_CSI_support_history_and_autocompletion.3f"><a href="#sec:Does_CSI_support_history_and_autocompletion.3f">Does CSI support history and autocompletion?</a></h4><p>CSI doesn't support it natively but it can be activated with one of the <a href="http://wiki.call-cc.org/egg/readline">readline</a>, <a href="http://wiki.call-cc.org/egg/linenoise">linenoise</a> or <a href="http://wiki.call-cc.org/egg/parley">parley</a> eggs. Out of these three, the parley egg is recommended. After installing parley, add the following to your <tt>~/.csirc</tt> or equivalent file:</p>
<pre class="highlight colorize"><span class="paren1">(<span class="default">use parley</span>)</span>
<span class="paren1">(<span class="default"><i><span class="symbol">let</span></i> <span class="paren2">(<span class="default"><span class="paren3">(<span class="default">old <span class="paren4">(<span class="default">current-input-port</span>)</span></span>)</span></span>)</span>
  <span class="paren2">(<span class="default">current-input-port <span class="paren3">(<span class="default">make-parley-port old</span>)</span></span>)</span></span>)</span></pre><p>Users of *nix-like systems (including Cygwin), may also want to check out <a href="http://utopia.knoware.nl/~hlub/rlwrap/">rlwrap</a>.  This program lets you &quot;wrap&quot; another process (e.g. <tt>rlwrap csi</tt>) with the readline library, giving you history, autocompletion, and the ability to set the keystroke set. Vi fans can get vi keystrokes by adding &quot;set editing-mode vi&quot; to their <tt>.inputrc</tt> file.</p><h4 id="sec:Does_code_loaded_with_load_run_compiled_or_interpreted.3f"><a href="#sec:Does_code_loaded_with_load_run_compiled_or_interpreted.3f">Does code loaded with <tt>load</tt> run compiled or interpreted?</a></h4><p>If you compile a file with a call to <tt>load</tt>, the code will be loaded at runtime and, if the file loaded is a Scheme source code file (instead of a shared object), it will be interpreted (even if the caller program is compiled).</p><h4 id="sec:How_do_I_use_extended_.28non-standard.29_syntax_in_evaluated_code_at_run-time.3f"><a href="#sec:How_do_I_use_extended_.28non-standard.29_syntax_in_evaluated_code_at_run-time.3f">How do I use extended (non-standard) syntax in evaluated code at run-time?</a></h4><p>Normally, only standard Scheme syntax is available to the evaluator. To use the extensions provided in the CHICKEN compiler and interpreter, add:</p>
<pre class="highlight colorize"><span class="paren1">(<span class="default">require-library chicken-syntax</span>)</span></pre><h3 id="sec:Extensions_"><a href="#sec:Extensions_">Extensions </a></h3><h4 id="sec:Where_is_.22chicken-setup.22_.3f"><a href="#sec:Where_is_.22chicken-setup.22_.3f">Where is &quot;chicken-setup&quot; ?</a></h4><p><tt>chicken-setup</tt> has been rewritten from scratch and its functionality is now contained in the three tools <tt>chicken-install</tt>, <tt>chicken-uninstall</tt> and <tt>chicken-status</tt>. See the <a href="Extensions.html">Extensions</a> chapter for more information.</p><h4 id="sec:How_can_I_install_CHICKEN_eggs_to_a_non-default_location.3f"><a href="#sec:How_can_I_install_CHICKEN_eggs_to_a_non-default_location.3f">How can I install CHICKEN eggs to a non-default location?</a></h4><p>You can just set the <tt>CHICKEN_REPOSITORY</tt> environment variable. It should contain the path where you want eggs to be installed:</p><pre>$ export CHICKEN_REPOSITORY=~/eggs/lib/chicken/5
$ chicken-install -init ~/eggs/lib/chicken/5
$ chicken-install -p ~/eggs/ extensionname</pre><p>In order to make programs (including csi) see these eggs, you should set this variable when you run them. See the <a href="Extensions.html#sec:Changing_repository_location">Extensions/Changing repository location</a> section of the manual for more information on that.</p><p>Alternatively, you can call the <tt>repository-path</tt> Scheme procedure before loading the eggs, as in:</p>
<pre class="highlight colorize"><span class="paren1">(<span class="default">repository-path <span class="string">&quot;/home/azul/eggs&quot;</span></span>)</span>
<span class="paren1">(<span class="default">use format-modular</span>)</span></pre><p>Note, however, that using <tt>repository-path</tt> as above hard-codes the location of your eggs in your source files.  While this might not be an issue in your case, it might be safe to keep this configuration outside of the source code (that is, specifying it as an environment variable) to make it easier to maintain.</p><p>The repository needs to be initialized before use. See the documentation for the <tt>-init</tt> option to <tt>chicken-install</tt>, in <a href="Extensions.html">Extensions</a>.</p><h4 id="sec:Can_I_install_chicken_eggs_as_a_non-root_user.3f"><a href="#sec:Can_I_install_chicken_eggs_as_a_non-root_user.3f">Can I install chicken eggs as a non-root user?</a></h4><p>Yes, just install them in a directory you can write to by using <tt>CHICKEN_REPOSITORY</tt> (see above).</p><h4 id="sec:Why_does_downloading_an_extension_via_chicken-install_fail_on_Windows_Vista.3f"><a href="#sec:Why_does_downloading_an_extension_via_chicken-install_fail_on_Windows_Vista.3f">Why does downloading an extension via <tt>chicken-install</tt> fail on Windows Vista?</a></h4><p>Possibly the Windows Firewall is active, which prevents <tt>chicken-install</tt> from opening a TCP connection to the egg repository. Try disabling the firewall temporarily.</p><hr /><p>Previous: <a href="Bugs%20and%20limitations.html">Bugs and limitations</a></p><p>Next: <a href="Acknowledgements.html">Acknowledgements</a></p></div></div></body>