~ chicken-core (chicken-5) b5a1c5cf1625f768c67773aa32db529ac80df72f
commit b5a1c5cf1625f768c67773aa32db529ac80df72f
Author: felix <felix@call-with-current-continuation.org>
AuthorDate: Tue Mar 9 07:40:01 2010 +0100
Commit: felix <felix@call-with-current-continuation.org>
CommitDate: Tue Mar 9 07:40:01 2010 +0100
merged with wiki manual
diff --git a/manual/C interface b/manual/C interface
index c94fbbe8..e2f1550f 100644
--- a/manual/C interface
+++ b/manual/C interface
@@ -91,10 +91,90 @@ These macros return immediate Scheme data objects.
[C function] C_word C_list (C_word **ptr, int length, ...)
+=== C_closure
+
+ [C function] C_word C_closure (C_word **ptr, int length, C_word procedure, ...)
+
These functions allocate memory from {{ptr}} and initialize a fresh
data object. The new data object is returned. {{ptr}} should be the
'''address''' of an allocation pointer created with {{C_alloc}}.
+To find out how big the memory block should be, use the {{C_SIZEOF_*}}
+macros described below.
+
+Here's an example how to create a closure that accepts a vector,
+stores the Scheme numbers 1, 2 and 3 and a given string in it and
+returns that vector to its continuation:
+
+<enscript highlight=scheme>
+#>
+
+#include <assert.h>
+
+void fill_vector(C_word c, C_word closure, C_word vec)
+{
+ C_word kontinuation = C_block_item(closure, 1);
+
+ C_block_item(vec, 0) = C_fix(1);
+ C_block_item(vec, 1) = C_fix(2);
+ C_block_item(vec, 2) = C_fix(3);
+ C_block_item(vec, 3) = C_block_item(closure, 2);
+
+ C_kontinue(kontinuation, vec);
+}
+
+void one_two_three(C_word c, C_word self, C_word k, C_word str)
+{
+ /*
+ * Allocate room on the stack to hold the closure: 1 word for
+ * the type tag, 1 word for the procedure and 2 words for the
+ * values "closed over"; this procedure's continuation "k" and
+ * the argument "str". We could also use C_alloc(4).
+ */
+ C_word closure[4], *cp = closure;
+
+ /* Create the closure. It holds 3 values, not counting the tag */
+ C_word closure_object = C_closure(&cp, 3, (C_word)fill_vector, k, str);
+
+ /*
+ * After this, cp points just beyond the last word of the allocated
+ * data and closure_object is an opaque representation of the newly
+ * created closure as a whole, i.e. the following relations hold:
+ */
+ assert( (closure + 4) == cp );
+ assert( C_block_header(closure_object) == (*closure) );
+ assert( C_data_pointer(closure_object) == (closure + 1) );
+ assert( C_block_item(closure_object, 0) == (*(closure + 1)) );
+
+ /* Make a vector of 4 objects and use closure_object as continuation */
+ C_allocate_vector(6, (C_word)NULL, closure_object, C_fix(4),
+ C_SCHEME_FALSE, /* not a byte vector */
+ C_SCHEME_FALSE, /* initialization value. Don't care */
+ C_SCHEME_FALSE); /* don't align at 8 bytes */
+ /* .. C_allocate_vector does not return ... */
+}
+<#
+
+(define one-two-three (##core#primitive "one_two_three"))
+
+(print (one-two-three "hi"))
+</enscript>
+
+This is equivalent to the following in Scheme:
+
+<enscript highlight=scheme>
+(define (one-two-three str)
+ (let ((fill-vector (lambda (vec)
+ (vector-set! vec 0 1)
+ (vector-set! vec 1 2)
+ (vector-set! vec 2 3)
+ (vector-set! vec 3 str)
+ vec)))
+ (fill-vector (make-vector 4 #f))))
+
+(print (one-two-three "hi"))
+</enscript>
+
=== C_alloc
@@ -185,7 +265,6 @@ back to C data. Note that {{C_c_string()}} returns a pointer
to the character buffer of the actual Scheme object and is not
zero-terminated.
-
=== C_header_size
[C macro] int C_header_size (C_word x)
diff --git a/manual/Deviations from the standard b/manual/Deviations from the standard
index b7a6bd2f..a36dd3e9 100644
--- a/manual/Deviations from the standard
+++ b/manual/Deviations from the standard
@@ -60,6 +60,8 @@ lambda-expressions.
== Non-deviations that might surprise you
+[4.3.1] {{let-syntax}} and {{letrec-syntax}} introduce a new scope.
+
[6.1] {{equal?}} compares all structured data recursively, while R5RS
specifies that {{eqv?}} is used for data other than pairs, strings and
vectors. However, R5RS does not dictate the treatment of data types
diff --git a/manual/Extensions b/manual/Extensions
index d0cb50d9..6c25f6c4 100644
--- a/manual/Extensions
+++ b/manual/Extensions
@@ -461,7 +461,7 @@ Available options:
; {{-s -sudo}} : use {{sudo(1)}} for installing or removing files
; {{-r -retrieve}} : only retrieve egg into current directory, don't install
; {{-n -no-install}} : do not install, just build (implies {{-keep}})
-; {{-p -prefix PREFIX}} : change installation prefix to {{PREFIX}}; note: this must be an absolute path
+; {{-p -prefix PREFIX}} : change installation prefix to {{PREFIX}}
; {{-host}} : when cross-compiling, compile extension for host
; {{-test}} : run included test-cases, if available
; {{-username USER}} : set username for transports that require this
diff --git a/manual/Getting started b/manual/Getting started
index 63cad4a1..b359d2ef 100644
--- a/manual/Getting started
+++ b/manual/Getting started
@@ -196,7 +196,7 @@ other useful documents. The list of eggs is at
A very useful search facility for questions about Chicken is found at
[[http://www.callcc.org]]. The Chicken issue tracker is at
-[[http://trac.callcc.org]].
+[[http://www.irp.oist.jp/trac/chicken/wiki]].
The Chicken community has two major mailing lists. If you are a
Chicken user, {{Chicken-Users}}
diff --git a/manual/The User's Manual b/manual/The User's Manual
index c7e1a084..88bdc882 100644
--- a/manual/The User's Manual
+++ b/manual/The User's Manual
@@ -6,7 +6,7 @@
<img style="float:right; border-left:1px solid #ccc;border-bottom:1px solid #ccc;margin-left:1em;" src="http://www.call-with-current-continuation.org/chicken4.png" alt="Stylized picture of a chicken"/>
</nowiki>
-This is the manual for Chicken Scheme, version 4.3.7
+This is the manual for Chicken Scheme, version 4.4.0
; [[Getting started]] : What is CHICKEN and how do I use it?
diff --git a/manual/Unit files b/manual/Unit files
index f0ff1c99..7d9e0985 100644
--- a/manual/Unit files
+++ b/manual/Unit files
@@ -27,8 +27,8 @@ For any component that is not contained in {{PATHNAME}}, {{#f}} is returned.
==== make-pathname
==== make-absolute-pathname
-<procedure>(make-pathname DIRECTORY FILENAME [EXTENSION [SEPARATOR]])</procedure><br>
-<procedure>(make-absolute-pathname DIRECTORY FILENAME [EXTENSION [SEPARATOR]])</procedure>
+<procedure>(make-pathname DIRECTORY FILENAME [EXTENSION])</procedure><br>
+<procedure>(make-absolute-pathname DIRECTORY FILENAME [EXTENSION])</procedure>
Returns a string that names the file with the
components {{DIRECTORY, FILENAME}} and (optionally)
@@ -40,8 +40,6 @@ directory component), a string or a list of strings. {{FILENAME}}
and {{EXTENSION}} should be strings or {{#f}}.
{{make-absolute-pathname}} returns always an absolute pathname.
-The {{[SEPARATOR]}} argument is deprecated.
-
==== pathname-directory
==== pathname-file
==== pathname-extension
diff --git a/manual/Unit library b/manual/Unit library
index 8c707302..676e4aef 100644
--- a/manual/Unit library
+++ b/manual/Unit library
@@ -1224,7 +1224,7 @@ be compared using {{eq?}}.
==== get
- <procedure>(get SYMBOL PROPERTY [DEFAULT])</procedure>
+<procedure>(get SYMBOL PROPERTY [DEFAULT])</procedure>
Returns the value stored under the key {{PROPERTY}} in the property
list of {{SYMBOL}}. If no such property is stored, returns
@@ -1232,29 +1232,29 @@ list of {{SYMBOL}}. If no such property is stored, returns
==== put!
- <procedure>(put! SYMBOL PROPERTY VALUE)</procedure>
- [setter] (set! (get SYMBOL PROPERTY) VALUE)
+<procedure>(put! SYMBOL PROPERTY VALUE)</procedure>
+setter: (set! (get SYMBOL PROPERTY) VALUE)
Stores {{VALUE}} under the key {{PROPERTY}} in the property list of
{{SYMBOL}} replacing any previously stored value.
==== remprop!
- <procedure>(remprop! SYMBOL PROPERTY)</procedure>
+<procedure>(remprop! SYMBOL PROPERTY)</procedure>
Deletes the first property matching the key {{PROPERTY}} in the property list
of {{SYMBOL}}. Returns {{#t}} when a deletion performed, and {{#f}} otherwise.
==== symbol-plist
- <procedure>(symbol-plist SYMBOL)</procedure>
- [setter] (set! (symbol-plist SYMBOL) LST)
+<procedure>(symbol-plist SYMBOL)</procedure>
+setter: (set! (symbol-plist SYMBOL) LST)
Returns the property list of {{SYMBOL}} or sets it.
==== get-properties
- <procedure>(get-properties SYMBOL PROPERTIES)</procedure>
+<procedure>(get-properties SYMBOL PROPERTIES)</procedure>
Searches the property list of {{SYMBOL}} for the first property with a key in
the list {{PROPERTIES}}. Returns 3 values: the matching property key, value,
diff --git a/manual/Using the interpreter b/manual/Using the interpreter
index 10e558ad..c1804906 100644
--- a/manual/Using the interpreter
+++ b/manual/Using the interpreter
@@ -79,7 +79,7 @@ The easiest way is to use the {{-script}} option like this:
read)))
% chmod +x foo
- % foo "(+ 3 4)"
+ % ./foo "(+ 3 4)"
7
The parameter {{command-line-arguments}} is set to a list of the
Trap