From e0a8221dcf0c6592a968a10e511a69bb05728753 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Thu, 22 Dec 2011 09:32:09 -0500 Subject: Make the "Dia Primitives" section of the manual more clear. * doc/ref/libguile-program.texi (Dia Primitives): Use scm_assert_smob_type, and update the text. --- doc/ref/libguile-program.texi | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'doc') diff --git a/doc/ref/libguile-program.texi b/doc/ref/libguile-program.texi index 2c30d246e..f565b916f 100644 --- a/doc/ref/libguile-program.texi +++ b/doc/ref/libguile-program.texi @@ -279,13 +279,12 @@ As an example, here is a possible implementation of the @code{square?} primitive: @lisp -#define FUNC_NAME "square?" static SCM square_p (SCM shape) @{ struct dia_guile_shape * guile_shape; /* Check that arg is really a shape SMOB. */ - SCM_VALIDATE_SHAPE (SCM_ARG1, shape); + scm_assert_smob_type (shape_tag, shape); /* Access Scheme-specific shape structure. */ guile_shape = SCM_SMOB_DATA (shape); @@ -295,7 +294,6 @@ static SCM square_p (SCM shape) return scm_from_bool (guile_shape->c_shape && (guile_shape->c_shape->type == DIA_SQUARE)); @} -#undef FUNC_NAME @end lisp Notice how easy it is to chain through from the @code{SCM shape} @@ -303,10 +301,11 @@ parameter that @code{square_p} receives --- which is a SMOB --- to the Scheme-specific structure inside the SMOB, and thence to the underlying C structure for the shape. -In this code, @code{SCM_SMOB_DATA} and @code{scm_from_bool} are from -the standard Guile API. @code{SCM_VALIDATE_SHAPE} is a macro that you -should define as part of your SMOB definition: it checks that the -passed parameter is of the expected type. This is needed to guard +In this code, @code{scm_assert_smob_type}, @code{SCM_SMOB_DATA}, and +@code{scm_from_bool} are from the standard Guile API. We assume that +@code{shape_tag} was given to us when we made the shape SMOB type, using +@code{scm_make_smob_type}. The call to @code{scm_assert_smob_type} +ensures that @var{shape} is indeed a shape. This is needed to guard against Scheme code using the @code{square?} procedure incorrectly, as in @code{(square? "hello")}; Scheme's latent typing means that usage errors like this must be caught at run time. -- cgit v1.2.1 From 2f50d0a89758894a39bcec5a94c658d63d20701b Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Fri, 30 Dec 2011 23:26:32 -0500 Subject: Fix documentation for vhash-fold and vhash-fold-right * doc/ref/api-compound.texi (VHashes): Add missing `init' parameter in documentation for vhash-fold and vhash-fold-right, and also improve description. * module/ice-9/vlist.scm (vhash-fold, vhash-fold-right): Rename formal parameter `seed' to `init', to match documentation. Improve docstrings. --- doc/ref/api-compound.texi | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'doc') diff --git a/doc/ref/api-compound.texi b/doc/ref/api-compound.texi index c52fed42c..da8ca9199 100644 --- a/doc/ref/api-compound.texi +++ b/doc/ref/api-compound.texi @@ -3293,10 +3293,13 @@ Again the choice of @var{hash-proc} must be consistent with previous calls to @code{vhash-cons}. @end deffn -@deffn {Scheme Procedure} vhash-fold proc vhash -@deffnx {Scheme Procedure} vhash-fold-right proc vhash -Fold over the key/value elements of @var{vhash} in the given direction. -For each pair call @var{proc} as @code{(@var{proc} key value result)}. +@deffn {Scheme Procedure} vhash-fold proc init vhash +@deffnx {Scheme Procedure} vhash-fold-right proc init vhash +Fold over the key/value elements of @var{vhash} in the given direction, +with each call to @var{proc} having the form @code{(@var{proc} key value +result)}, where @var{result} is the result of the previous call to +@var{proc} and @var{init} the value of @var{result} for the first call +to @var{proc}. @end deffn @deffn {Scheme Procedure} vhash-fold* proc init key vhash [equal? [hash]] -- cgit v1.2.1 From aed9483ba1c22d5de5f3ec4b5b915e2095e233be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 3 Jan 2012 23:31:30 +0100 Subject: doc: Fix typo in `define-wrapped-pointer-type' example. * doc/ref/api-foreign.texi (Void Pointers and Byte Access): Fix typo in `define-wrapped-pointer-type' example. --- doc/ref/api-foreign.texi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/ref/api-foreign.texi b/doc/ref/api-foreign.texi index 2dd691675..82925e68d 100644 --- a/doc/ref/api-foreign.texi +++ b/doc/ref/api-foreign.texi @@ -1,7 +1,7 @@ @c -*-texinfo-*- @c This is part of the GNU Guile Reference Manual. @c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004, 2007, 2008, -@c 2009, 2010, 2011 Free Software Foundation, Inc. +@c 2009, 2010, 2011, 2012 Free Software Foundation, Inc. @c See the file guile.texi for copying conditions. @node Foreign Function Interface @@ -680,7 +680,7 @@ pointers to manipulate them. We could write: (lambda (b p) (format p "#" (bottle-contents b) - (pointer-address (unwrap-foo b))))) + (pointer-address (unwrap-bottle b))))) (define grab-bottle ;; Wrapper for `bottle_t *grab (void)'. -- cgit v1.2.1 From 4dbd29a9b8ea272fde54dcb0e8f47e23961f65d2 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Wed, 4 Jan 2012 13:43:47 -0500 Subject: Fix docs of string mutators to do so on a mutable string * doc/ref/api-data.texi (String Modification): Change (define y "abcdefg") => (define y (string-copy "abcdefg")) before mutating the string bound to y in the example code. --- doc/ref/api-data.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi index 5017165c0..f2450cea2 100644 --- a/doc/ref/api-data.texi +++ b/doc/ref/api-data.texi @@ -3366,7 +3366,7 @@ Change every character in @var{str} between @var{start} and @var{end} to @var{fill}. @lisp -(define y "abcdefg") +(define y (string-copy "abcdefg")) (substring-fill! y 1 3 #\r) y @result{} "arrdefg" -- cgit v1.2.1