source: project/chicken/branches/prerelease/manual/faq @ 14954

Last change on this file since 14954 was 14954, checked in by felix winkelmann, 10 years ago

merged trunk rev. 14940 into prerelease branch

File size: 27.2 KB
Line 
1[[toc:]]
2[[tags:faq]]
3
4== FAQ
5
6This is the list of Frequently Asked Questions about Chicken Scheme.
7If you have a question not answered here, feel free to post to the chicken-users mailing list;
8if you consider your question general enough, feel free to add it to this list.
9
10=== General
11
12==== Why yet another Scheme implementation?
13
14Since Scheme is a relatively simple language, a large number of implementations exist and
15each has its specific advantages and disadvantages. Some are fast, some provide a rich
16programming environment. Some are free, others are tailored to specific domains, and so on. The reasons
17for the existence of CHICKEN are:
18
19* CHICKEN is portable because it generates C code that runs on a large number of platforms.
20
21* CHICKEN is extendable, since its code generation scheme and runtime system/garbage collector fits neatly into a C environment.
22
23* CHICKEN is free and can be freely distributed, including its source code.
24
25* CHICKEN offers better performance than nearly all interpreter based implementations, but still provides full Scheme semantics.
26
27* As far as we know, CHICKEN is the first implementation of Scheme that uses Henry Baker's [[http://home.pipeline.com/~hbaker1/CheneyMTA.html|Cheney on the M.T.A]] concept.
28
29==== What should I do if I find a bug?
30
31Send e-mail to felix@call-with-current-continuation.org
32with some hints about the problem, like
33version/build of the compiler, platform, system configuration, code that
34causes the bug, etc.
35
36=== Specific
37
38==== Why are values defined with {{define-foreign-variable}} or {{define-constant}} or {{define-inline}} not seen outside of the containing source file?
39
40Accesses to foreign variables are translated directly into C constructs that access the variable,
41so the Scheme name given to that variable does only exist during compile-time.
42The same goes for constant- and inline-definitions: The name is only there to tell the compiler
43that this reference is to be replaced with the actual value.
44
45==== How does {{cond-expand}} know which features are registered in used units?
46
47Each unit used via {{(declare (uses ...))}} is registered as a feature and
48so a symbol with the unit-name can be tested by {{cond-expand}} during macro-expansion-time.
49Features registered using the {{register-feature!}} procedure are only
50available during run-time of the compiled file. You can use the {{eval-when}} form
51to register features at compile time.
52
53==== Why are constants defined by {{define-constant}} not honoured in {{case}} constructs?
54
55{{case}} expands into a cascaded {{if}} expression, where the first item in each arm
56is treated as a quoted list. So the {{case}} macro can not infer whether
57a symbol is to be treated as a constant-name (defined via {{define-constant}}) or
58a literal symbol.
59
60
61==== How can I enable case sensitive reading/writing in user code?
62
63To enable the {{read}} procedure to read symbols and identifiers case sensitive, you can set the
64parameter {{case-sensitivity}} to {{#t}}.
65
66
67==== Why doesn't CHICKEN support the full numeric tower by default?
68
69The short answer:
70
71<enscript highlight=scheme>
72% chicken-install numbers
73% csi -q
74#;1> (use numbers)
75</enscript>
76
77The long answer:
78
79There are a number of reasons for this:
80
81- For most applications of Scheme fixnums (exact word-sized integers) and flonums (64-bit floating-point
82numbers) are more than sufficient;
83
84- Interfacing to C is simpler;
85
86- Dispatching of arithmetic operations is more efficient.
87
88There is an extension based on the GNU Multiprecision Package that implements most of the full
89numeric tower, see [[http://chicken.wiki.br/egg/numbers|numbers]].
90
91
92==== Does CHICKEN support native threads?
93
94Native threads are not supported for two reasons. One, the runtime
95system is not reentrant.  Two, concurrency implemented properly would
96require mandatory locking of every object that could be potentially
97shared between two threads. The garbage-collection algorithm would
98then become much more complex and inefficient, since the location of
99every object has to be accessed via a thread synchronization
100protocol. Such a design would make native threads in Chicken
101essentially equivalent to Unix processes and shared memory.
102
103For a different approach to concurrency, please see the
104[[http://www.call-with-current-continuation.org/eggs/3/mpi.html|mpi]]
105egg.
106
107==== Does CHICKEN support Unicode strings?
108
109The system does not directly support Unicode, but an extension for UTF8 strings
110exists for CHICKEN 3, which may be ported to the current CHICKEN version at some
111stage.
112
113=== Why are `dynamic-wind' thunks not executed when a SRFI-18 thread signals an error?
114
115Here is what Marc Feeley, the author of [[http://srfi.schemers.org/srfi-18|SRFI-18]] has to
116say about this subject:
117
118    >No the default exception handler shouldn't invoke the after
119    > thunks of the current continuation.  That's because the
120    > exception handler doesn't "continue" at the initial
121    > continuation of that thread.  Here are the relevant words of
122    > SRFI 18:
123   
124    >
125    >  Moreover, in this dynamic environment the exception handler
126    >  is bound to the "initial exception handler" which is a unary
127    >  procedure which causes the (then) current thread to store in
128    >  its end-exception field an "uncaught exception" object whose
129    >  "reason" is the argument of the handler, abandon all mutexes
130    >  it owns, and finally terminate.
131    >
132   
133    >The rationale is that, when an uncaught exception occurs in a
134    >thread the thread is in bad shape and things have gone
135    >sufficiently wrong that there is no universally acceptable way to
136    >continue execution.  Executing after thunks could require a
137    >whole lot of processing that the thread is not in a shape to do.
138    >So the safe thing is to terminate the thread.  If the programmer
139    >knows how to recover from an exception, then he can capture the
140    >continuation early on, and install an exception handler which
141    >invokes the continuation.  When the continuation is invoked the
142    >after thunks will execute.
143
144
145=== Platform specific
146
147==== How do I generate a DLL under MS Windows (tm) ?
148
149Use {{csc}} in combination with the {{-dll}} option:
150
151{{C:\> csc foo.scm -dll}}
152
153==== How do I generate a GUI application under Windows(tm)?
154
155Invoke {{csc}} with the {{-windows}} option. Or pass the {{-DC_WINDOWS_GUI}}
156option to the C compiler and link with the GUI version of the runtime system (that's {{libchicken-gui[-static].lib}}.
157The GUI runtime displays error messages in a message box and does some rudimentary command-line
158parsing.
159
160==== Compiling very large files under Windows with the Microsoft C compiler fails with a message indicating insufficient heap space.
161
162It seems that the Microsoft C compiler can only handle files up to a certain size, and it doesn't utilize virtual memory as
163well as the GNU C compiler, for example. Try closing running applications. If that fails, try to break up the Scheme code
164into several library units.
165
166==== When I run {{csi}} inside an emacs buffer under Windows, nothing happens.
167
168Invoke {{csi}} with the {{-:c}} runtime option. Under Windows the interpreter thinks it
169is not running under control of a terminal and doesn't print the prompt and does not flush the output stream properly.
170
171==== I load compiled code dynamically in a Windows GUI application and it crashes.
172
173Code compiled into a DLL to be loaded dynamically must be linked with the same runtime system as the loading
174application. That means that all dynamically loaded entities (including extensions built and installed with
175{{chicken-install}}) must be compiled with the {{-windows}} {{csc}} option.
176
177==== On Windows, {{csc.exe}} seems to be doing something wrong.
178
179The Windows development tools include a C# compiler with the same name. Either invoke {{csc.exe}} with a full
180pathname, or put the directory where you installed CHICKEN in front of the MS development tool path in the {{PATH}}
181environment variable.
182
183==== On Windows source and/or output filenames with embedded whitespace are not found.
184
185There is no current workaround. Do not use filenames with embedded whitespace for code. However, command
186names with embedded whitespace will work correctly.
187=== Customization
188
189
190==== How do I run custom startup code before the runtime-system is invoked?
191
192When you invoke the C compiler for your translated Scheme source program, add the C compiler option
193{{-DC_EMBEDDED}}, or pass {{-embedded}} to the {{csc}}
194driver program, so no entry-point function will be generated ({{main()}}).
195When your are finished with your startup processing, invoke:
196
197<enscript highlight=c>
198CHICKEN_main(argc, argv, C_toplevel);
199</enscript>
200
201where {{C_toplevel}} is the entry-point into the compiled Scheme code. You
202should add the following  declarations at the head of your code:
203
204<enscript highlight=c>
205#include "chicken.h"
206extern void C_toplevel(C_word,C_word,C_word) C_noret;
207</enscript>
208
209==== How can I add compiled user passes?
210
211To add a compiled user pass instead of an interpreted one, create a library unit and recompile
212the main unit of the compiler (in the file {{chicken.scm}}) with an additional {{uses}}
213declaration. Then link all compiler modules and your (compiled) extension to create a new version of
214the compiler, like this (assuming all sources are in the
215current directory):
216
217<enscript highlight=scheme>
218  % cat userpass.scm
219  ;;;; userpass.scm - My very own compiler pass
220
221  (declare (unit userpass))
222
223  ;; Perhaps more user passes/extensions are added:
224  (let ([old (user-pass)])
225    (user-pass
226      (lambda (x)
227        (let ([x2 (do-something-with x)])
228           (if old
229               (old x2)
230               x2) ) ) ) )
231</enscript>
232
233 % csc -c -x userpass.scm
234 % csc chicken.scm -c -o chicken-extended.o -uses userpass
235 % gcc chicken-extended.o support.o easyffi.o compiler.o optimizer.o batch-driver.o c-platform.o \
236 c-backend.o userpass.o `csc -ldflags -libs` -o chicken-extended
237
238On platforms that support it (Linux ELF, Solaris, Windows + VC++), compiled code can be loaded via {{-extend}}
239just like source files (see {{load}} in the User's Manual).
240
241
242=== Macros
243
244==== Where is {{define-macro}}?
245
246With CHICKEN 4, the macro-expansion subsystem is now hygienic where old Lisp-style low-level macros
247are not available anymore. {{define-syntax}} can define hygienic macros using {{syntax-rules}}
248or low-level macros with user-controlled hygienic with ''explicit renaming'' macros. Translating
249old-style macros into ER-macros isn't that hard, see [[Modules and macros]] for more information.
250
251==== Why are low-level macros defined with {{define-syntax}} complaining about unbound variables?
252
253Macro bodies that are defined and used in a compiled source-file are
254evaluated during compilation and so have no access to anything created with {{define}}. Use {{define-for-syntax}} instead.
255
256==== Why isn't {{load}} properly loading my library of macros?
257
258During compile-time, macros are only available in the source file in which they are defined. Files included via {{include}} are considered part of the containing file.
259
260=== Warnings and errors
261
262==== Why does my program crash when I use callback functions (from Scheme to C and back to Scheme again)?
263
264There are two reasons why code involving callbacks can crash out of no apparent reason:
265
266# It is important to use {{foreign-safe-lambda/foreign-safe-lambda*}} 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.
267
268# 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 {{-:s...}} and a larger value than the default (for example {{-:s300k}}), or use the {{-nursery}} compiler option.  Note that this can decrease runtime performance on some platforms.
269
270==== Why does the linker complain about a missing function {{_C_..._toplevel}}?
271
272This message indicates that your program uses a library-unit, but that the
273object-file or library was not supplied to the linker. If you have the unit
274{{foo}}, which is contained in {{foo.o}} than you have to supply it to the
275linker like this (assuming a GCC environment):
276
277{{% csc program.scm foo.o -o program}}
278
279==== Why does the linker complain about a missing function {{_C_toplevel}}?
280
281This means you have compiled a library unit as an application. When a unit-declaration (as in {{(declare (unit ...))}})
282is given, then this file has a specially named toplevel entry procedure. Just remove the declaration,
283or compile this file to an object-module and link it to your application code.
284
285==== Why does my program crash when I compile a file with {{-unsafe}} or unsafe declarations?
286
287The compiler option {{-unsafe}} or the declaration {{(declare (unsafe))}} disable
288certain safety-checks to improve performance, so code that would normally
289trigger an error will work unexpectedly or even crash the running application.
290It is advisable to develop and debug a program in safe mode (without unsafe
291declarations) and use this feature only if the application works properly.
292
293==== Why don't toplevel-continuations captured in interpreted code work?
294
295Consider the following piece of code:
296
297<enscript highlight=scheme> 
298(define k (call-with-current-continuation (lambda (k) k)))
299(k k)
300</enscript>
301
302When compiled, this will loop endlessly. But when interpreted, {{(k k)}} will return
303to the read-eval-print loop! This happens because the continuation captured will eventually read the
304next toplevel expression from the standard-input (or an input-file if loading from a file). At the moment
305{{k}} was defined, the next expression was {{(k k)}}. But when {{k}}
306is invoked, the next expression will be whatever follows after {{(k k)}}.
307In other words, invoking a captured continuation will not rewind the file-position of the input source.
308A solution is to wrap the whole code into a {{(begin ...)}} expression, so all toplevel
309expressions will be loaded together.
310
311==== Why does {{define-reader-ctor}} not work in my compiled program?
312
313The following piece of code does not work as expected:
314
315<enscript highlight=scheme>
316 (eval-when (compile)
317 (define-reader-ctor 'integer->char integer->char) )
318 (print #,(integer->char 33))
319</enscript>
320
321The problem is that the compiler reads the complete source-file before doing any processing on it,
322so the sharp-comma form is encountered before the reader-ctor is defined. A possible solution is to include
323the file containing the sharp-comma form, like this:
324
325<enscript highlight=scheme>
326 (eval-when (compile)
327 (define-reader-ctor 'integer->char integer->char) )
328 
329 (include "other-file")
330</enscript>
331
332<enscript highlight=scheme>
333 ;;; other-file.scm:
334 (print #,(integer->char 33))
335</enscript>
336
337==== Why do built-in units, such as srfi-1, srfi-18, and posix fail to load?
338
339When you try to {{use}} a built-in unit such as {{srfi-18}}, you may get the following error:
340
341<enscript highlight=scheme>
342 #;1> (use srfi-18)
343 ; loading library srfi-18 ...
344 Error: (load-library) unable to load library
345 srfi-18
346 "dlopen(libchicken.dylib, 9): image not found"                ;; on a Mac
347 "libchicken.so: cannot open shared object file: No such file or directory"  ;; Linux
348</enscript>
349
350Another symptom is that {{(require 'srfi-18)}} will silently fail.
351
352This 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:
353
354 export DYLD_LIBRARY_PATH=~/scheme/chicken/lib:$DYLD_LIBRARY_PATH ;; Mac
355 export LD_LIBRARY_PATH=~/scheme/chicken/lib:$LD_LIBRARY_PATH    ;; Linux
356
357==== How can I increase the size of the trace shown when runtime errors are detected?
358
359When a runtime error is detected, Chicken will print the last entries from the trace of functions called
360(unless your executable was compiled with the {{-no-trace}} option.
361By default, only 16 entries will be shown.
362To increase this number pass the {{-:aN}} parameter to your executable.
363
364
365=== Optimizations
366
367==== How can I obtain smaller executables?
368
369If you don't need {{eval}} or the stuff in the {{extras}} library unit,
370you can just use the {{library}} unit:
371
372<enscript highlight=scheme>
373        (declare (uses library))
374        (display "Hello, world!\n")
375</enscript>
376
377(Don't forget to compile with the {{-explicit-use}} option)
378Compiled with Visual C++ this generates an executable of around 240 kilobytes.
379It is theoretically possible to compile something without the library, but
380a program would have to implement quite a lot of support code on its own.
381
382==== How can I obtain faster executables?
383
384There are a number of declaration specifiers that should be used to speed up
385compiled files: declaring {{(standard-bindings)}} is mandatory, since this enables
386most optimizations. Even if some standard procedures should be redefined, you can
387list untouched bindings in the declaration.
388Declaring {{(extended-bindings)}} lets the compiler choose faster versions of certain
389internal library functions. This might give another speedup. You can also use the
390the {{usual-integrations}} declaration, which is identical to declaring
391{{standard-bindings}} and {{extended-bindings}}
392(note that {{usual-integrations}} is set by default).
393Declaring {{(block)}} tells the compiler that global procedures are not changed
394outside the current compilation unit, this gives the compiler some more
395opportunities for optimization.
396If no floating point arithmetic is required, then declaring {{(number-type fixnum)}}
397can give a big performance improvement, because the compiler can now inline
398most arithmetic operations.
399Declaring {{(unsafe)}} will switch off most safety checks.
400If threads are not used, you can declare {{(disable-interrupts)}}.
401You should always use maximum optimizations settings for your C compiler.
402Good GCC compiler options on Pentium (and compatible) hardware are:
403{{-Os -fomit-frame-pointer -fno-strict-aliasing}}
404Some programs are very sensitive to the setting of the nursery (the first heap-generation). You
405should experiment with different nursery settings (either by compiling with the {{-nursery}}
406option or by using the {{-:s...}} runtime option).
407
408==== Which non-standard procedures are treated specially when the {{extended-bindings}} or {{usual-integrations}} declaration or compiler option is used?
409
410The following standard bindings are handled specially, depending on optimization options
411and compiler settings:
412
413{{+}} {{*}} {{-}} {{/}} {{quotient}} {{eq?}} {{eqv?}} {{equal?}} {{apply}} {{c...r}} {{values}} {{call-with-values}}
414{{list-ref}} {{null?}} {{length}} {{not}} {{char?}} {{string?}} {{symbol?}} {{vector?}} {{pair?}} {{procedure?}}
415{{boolean?}} {{number?}} {{complex?}} {{rational?}} {{real?}} {{exact?}} {{inexact?}} {{list?}} {{eof-object?}}
416{{string-ref}} {{string-set!}} {{vector-ref}} {{vector-set!}} {{char=?}} {{char<?}} {{char>?}} {{char<=?}} {{char>=?}}
417{{char-numeric?}} {{char-alphabetic?}} {{char-whitespace?}} {{char-upper-case?}}
418{{char-lower-case?}} {{char-upcae}} {{char-downcase}} {{list-tail}} {{assv}} {{memv}} {{memq}} {{assoc}}
419{{member}} {{set-car!}} {{set-cdr!}} {{abs}} {{exp}} {{sin}} {{cos}} {{tan}} {{log}} {{asin}} {{acos}} {{atan}} {{sqrt}}
420{{zero?}} {{positive?}} {{negative?}} {{vector-length}} {{string-length}} {{char->integer}}
421{{integer->char}} {{inexact->exact}} {{=}} {{>}} {{<}} {{>=}} {{<=}} {{for-each}} {{map}} {{substring}}
422{{string-append}} {{gcd}} {{lcm}} {{list}} {{exact->inexact}} {{string->number}} {{number->string}}
423{{even?}} {{odd?}} {{remainder}} {{floor}} {{ceiling}} {{truncate}} {{round}} {{cons}} {{vector}} {{string}}
424{{string=?}} {{string-ci=?}} {{make-vector}} {{call-with-current-continuation}}
425{{write-char}} {{read-string}}
426
427The following extended bindings are handled specially:
428
429{{bitwise-and}} {{bitwise-ior}} {{bitwise-xor}} {{bitwise-not}}
430{{bit-set?}} {{add1}} {{sub1}}
431{{fx+}}
432{{fx-}} {{fx*}} {{fx/}} {{fxmod}}
433{{fx=}} {{fx>}} {{fx>=}} {{fixnum?}} {{fxneg}} {{fxmax}} {{fxmin}}
434{{fxand}} {{fxior}} {{fxxor}} {{fxnot}} {{fxshl}} {{fxshr}}
435{{flonum?}} {{fp+}}
436{{fp-}} {{fp*}} {{fp/}} {{atom?}}
437{{fp=}} {{fp>}} {{fp>=}} {{fpneg}} {{fpmax}} {{fpmin}}
438{{arithmetic-shift}} {{signum}} {{flush-output}} {{thread-specific}} {{thread-specific-set!}}
439{{not-pair?}} {{null-list?}} {{print}} {{print*}} {{u8vector->blob/shared}}
440{{s8vector->blob/shared}} {{u16vector->blob/shared}} {{s16vector->blob/shared}}
441{{u32vector->blob/shared}}
442{{s32vector->blob/shared}} {{f32vector->blob/shared}} {{f64vector->blob/shared}} {{block-ref}}
443{{blob-size}}
444{{u8vector-length}}
445{{s8vector-length}}
446{{u16vector-length}}
447{{s16vector-length}}
448{{u32vector-length}}
449{{s32vector-length}}
450{{f32vector-length}}
451{{f64vector-length}}
452{{u8vector-ref}}
453{{s8vector-ref}}
454{{u16vector-ref}}
455{{s16vector-ref}}
456{{u32vector-ref}}
457{{s32vector-ref}}
458{{f32vector-ref}}
459{{f64vector-ref}}
460{{u8vector-set!}}
461{{s8vector-set!}}
462{{u16vector-set!}}
463{{s16vector-set!}}
464{{u32vector-set!}}
465{{s32vector-set!}}
466{{hash-table-ref}}
467{{block-set!}} {{number-of-slots}}
468{{first}} {{second}} {{third}} {{fourth}} {{null-pointer?}} {{pointer->object}}
469{{make-record-instance}}
470{{locative-ref}} {{locative-set!}} {{locative?}} {{locative->object}} {{identity}}
471{{cpu-time}} {{error}} {{call/cc}} {{any?}}
472{{substring=?}} {{substring-ci=?}} {{substring-index}} {{substring-index-ci}}
473
474==== What's the difference betweem "block" and "local" mode?
475
476In {{block}} mode, the compiler assumes that definitions in the current file
477are not visible from outside of the current compilation unit, so unused
478definitions can be removed and calls can be inlined. In {{local}} mode,
479definitions are not hidden, but the compiler assumes that they are
480not modified from other compilation units (or code evaluated at runtime),
481and thus allows inlining of them.
482
483==== Can I load compiled code at runtime?
484
485Yes.
486You can load compiled at code at runtime with {{load}} just as
487well as you can load Scheme source code.
488Compiled code will, of course, run faster.
489
490To do this, pass to {{load}} a path for a shared object.
491Use a form such as {{(load "foo.so")}} and run
492{{csc -shared foo.scm}} to produce {{foo.so}} from {{foo.scm}} (at
493which point {{foo.scm}} will no longer be required).
494
495==== Why is my program which uses regular expressions so slow?
496
497The regular expression engine has recently be replaced by [[alex shinn]]'s excellent
498{{irregex}} library, which is fully implemented in Scheme. Precompiling regular
499expressions to internal form is somewhat slower than with the old PCRE-based
500regex engine. It is advisable to use {{regexp}} to precompile regular expressions
501outside of time-critical loops and use them where performance matters.
502
503
504=== Garbage collection
505
506==== Why does a loop that doesn't {{cons}} still trigger garbage collections?
507
508Under CHICKENs implementation policy, tail recursion is achieved simply by avoiding
509to return from a function call. Since the programs are CPS converted, a continuous
510sequence of nested procedure calls is performed. At some stage the stack-space has
511to run out and the current procedure and its parameters (including the current
512continuation) are stored somewhere in the runtime system. Now a minor garbage collection
513occurs and rescues all live
514data from the stack (the first heap generation) and moves it into the the second heap
515generation. Then the stack is cleared (using
516a {{longjmp}}) and execution can continue from the saved state.
517With this method arbitrary recursion (in tail- or non-tail position) can happen,
518provided the application doesn't run out of heap-space.
519(The difference between a tail- and a non-tail call is that the tail-call has no
520live data after it invokes its continuation - and so the amount of heap-space needed stays constant)
521
522==== Why do finalizers not seem to work in simple cases in the interpeter?
523
524Consider the following interaction in CSI:
525
526 #;1> (define x '(1 2 3))
527 #;2> (define (yammer x) (print x " is dead"))
528 #;3> (set-finalizer! x yammer)
529 (1 2 3)
530 #;4> (gc #t)
531 157812
532 #;5> (define x #f)
533 #;6> (gc #t)
534 157812
535 #;7>
536
537While you might expect objects to be reclaimed and "''(1 2 3) is dead''" printed, it won't happen:
538the literal list gets held in the interpreter history, because it is the
539result value of the set-finalizer! call.
540Running this in a normal program will work fine.
541
542When testing finalizers from the interpreter, you might want to define a trivial macro such as
543
544 (define-syntax v
545   (syntax-rules ()
546     ((_ x) (begin (print x) (void)))))
547
548and wrap calls to {{set-finalizer!}} in it.
549
550=== Interpreter
551
552==== Does CSI support history and autocompletion?
553
554CSI doesn't support it natively but it can be activated with the [[http://www.call-with-current-continuation.org/eggs/readline.html]] egg.
555After installing the egg, add the following to your {{~/.csirc}} or equivalent file:
556
557<enscript highlight=scheme>
558 (require-extension readline)
559 (current-input-port (make-gnu-readline-port))
560 (gnu-history-install-file-manager (string-append (or (getenv "HOME") ".") "/.csi.history"))
561</enscript>
562
563Users of *nix-like systems (including Cygwin), may also want to check out [[http://utopia.knoware.nl/~hlub/rlwrap/|rlwrap]].  This program lets you "wrap" another process (e.g. {{rlwrap csi}}) with the readline library, giving you history, autocompletion, and the ability to set the keystroke set. Vi fans can get vi keystrokes by adding "set editing-mode vi" to their {{.inputrc}} file.
564
565==== Does code loaded with {{load}} run compiled or interpreted?
566
567If you compile a file with a call to {{load}}, the code will be loaded at
568runtime and, if the file loaded is a Scheme source code file
569(instead of a shared object), it will be
570interpreted (even if the caller program is compiled).
571
572==== How do I use extended (non-standard) syntax in evaluated code at run-time?
573
574Normally, only standard Scheme syntax is available to the evaluator. To
575use the extensions provided in the CHICKEN compiler and interpreter,
576add:
577
578<enscript highlight=scheme>
579(require-library chicken-syntax)
580</enscript>
581
582=== Extensions
583
584==== Where is "chicken-setup" ?
585
586{{chicken-setup}} has been rewritten from scratch and its functionality is now
587contained in the three tools {{chicken-install}}, {{chicken-uninstall}} and {{chicken-status}}.
588See the [[Extensions]] chapter for more information.
589
590==== How can I install Chicken eggs to a non-default location?
591
592You can just set the {{CHICKEN_REPOSITORY}} environment variable.
593It should contain the path where you want eggs to be installed:
594
595 $ export CHICKEN_REPOSITORY=~/chicken/
596 $ chicken-install extensionname
597
598In order to make programs (including csi) see these eggs, you should set this variable when you run them.
599Alternatively, you can call the {{repository-path}} Scheme procedure before loading the eggs, as in:
600
601<enscript highlight=scheme>
602(repository-path "/home/azul/chicken")
603(use format-modular)
604</enscript>
605
606Note, however, that using {{repository-path}} 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.
607
608==== Can I install chicken eggs as a non-root user?
609
610Yes, just [[FAQ#Extensions#How can I install Chicken eggs to a non-default location?|install them in a directory you can write]].
611
612==== Why does downloading an extension via {{chicken-install}} fail on Windows Vista?
613
614Possibly the Windows Firewall is active, which prevents {{chicken-install}} from opening a TCP
615connection to the egg repository. Try disabling the firewall temporarily.
616
617---
618Previous: [[Bugs and limitations]]
619
620Next: [[Acknowledgements]]
Note: See TracBrowser for help on using the repository browser.