guile-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

guile/guile-core/doc intro.texi


From: Thien-Thi Nguyen
Subject: guile/guile-core/doc intro.texi
Date: Wed, 18 Jul 2001 00:09:43 -0700

CVSROOT:        /cvs
Module name:    guile
Branch:         branch_release-1-6
Changes by:     Thien-Thi Nguyen <address@hidden>       01/07/18 00:09:43

Modified files:
        guile-core/doc : intro.texi 

Log message:
        Fix spelling error.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/guile/guile-core/doc/intro.texi.diff?cvsroot=OldCVS&only_with_tag=branch_release-1-6&tr1=1.12.2.4&tr2=1.12.2.5&r1=text&r2=text

Patches:
Index: guile/guile-core/doc/intro.texi
diff -u guile/guile-core/doc/intro.texi:1.11 
guile/guile-core/doc/intro.texi:1.12
--- guile/guile-core/doc/intro.texi:1.11        Wed May 30 13:32:05 2001
+++ guile/guile-core/doc/intro.texi     Thu Jun 14 10:36:41 2001
@@ -1,4 +1,4 @@
address@hidden $Id: intro.texi,v 1.11 2001/05/30 20:32:05 mgrabmue Exp $
address@hidden $Id: intro.texi,v 1.12 2001/06/14 17:36:41 mvo Exp $
 
 @page
 @node What is Guile?
@@ -649,7 +649,7 @@
 void
 init_bessel ()
 @{
-  scm_make_gsubr ("j0", 1, 0, 0, j0_wrapper);
+  scm_c_define_gsubr ("j0", 1, 0, 0, j0_wrapper);
 @}
 @end smallexample
 
@@ -663,26 +663,27 @@
 For creating shared libraries portably, we recommend the use of
 @code{GNU Libtool}.
 
-A shared library can be loaded into a running Guile process with
address@hidden  After it has been linked you can call its exported
-functions via @code{dynamic-call}.  For our example, we are going to
-call the function @code{init_bessel} which will make @code{j0_wrapper}
-available to Scheme programs with the name @code{j0}.  Note that we do
-not specify a filename extension such as @file{.so} when invoking
address@hidden  The right extension for the host platform will be
-provided automatically.
+A shared library can be loaded into a running Guile process with the
+function @code{load-extension}.  In addition to the name of the
+library to load, this function also expects the name of function from
+that library that will be called to initialize it.  For our example,
+we are going to call the function @code{init_bessel} which will make
address@hidden available to Scheme programs with the name
address@hidden  Note that we do not specify a filename extension such as
address@hidden when invoking @code{load-extension}.  The right extension for
+the host platform will be provided automatically.
 
 @smalllisp
-(define bessel-lib (dynamic-link "libguile-bessel"))
-(dynamic-call "init_bessel" bessel-lib)
+(load-extension "libguile-bessel" "init_bessel")
 (j0 2)
 @result{} 0.223890779141236
 @end smalllisp
 
-For this to work, @code{dynamic-link} must be able to find
address@hidden, of course.  It will look in the places that are
-usual for your operating system, and it will additionally look into the
-directories listed in the @code{LTDL_LIBRRAY_PATH} environment variable.
+For this to work, @code{load-extension} must be able to find
address@hidden, of course.  It will look in the places that
+are usual for your operating system, and it will additionally look
+into the directories listed in the @code{LTDL_LIBRRAY_PATH}
+environment variable.
 
 To see how these Guile extensions via shared libraries relate to the
 module system, see below @xref{Intro to Modules and Extensions}.
@@ -722,7 +723,7 @@
 shows the complete list of directories searched:
 
 @smallexample
-guile -c '(for-each write-line %load-path)'
+guile -c '(write %load-path) (newline)'
 @end smallexample
 
 Suppose you want to use the procedures and variables exported by the
@@ -808,13 +809,15 @@
 @node Intro to Modules and Extensions
 @subsection Intro to Modules and Extensions
 
-In addition to Scheme code you can also put new procedures and other
-named features that are provided by an extension into a module.
+In addition to Scheme code you can also put things that are defined in
+C into a module.
 
 You do this by writing a small Scheme file that defines the module.
-That Scheme file in turn invokes @code{dynamic-link} and
address@hidden as explained above to make the extension
-available.
+That Scheme file in turn invokes @code{load-extension} to make the
+features defined in C available.  This works since all definitions
+made by @code{scm_c_define_gsubr} etc. go into the @emph{current
+module} and @code{define-module} causes the newly defined module to be
+current while the code that follows it is executed.
 
 Suppose we want to put the Bessel function @code{j0} from the example
 extension into a module called @code{(math bessel)}.  We would have to
@@ -823,12 +826,27 @@
 @smallexample
 (define-module (math bessel))
 
-(dynamic-call "init_bessel" (dynamic-link "libguile-bessel"))
+(export j0)
+
+(load-extension "libguile-bessel" "init_bessel")
 @end smallexample
 
-The file should of course be saved in the right place for autoloading,
-for example as @file{/usr/local/share/guile/math/bessel.scm}.
+This file should of course be saved in the right place for
+autoloading, for example as
address@hidden/usr/local/share/guile/math/bessel.scm}.
+
+When @code{init_bessel} is called, the new @code{(math bessel)} module
+is the current one.  Thus, the call to @code{scm_c_define_gsubr} will
+put the new definition for @code{j0} into it, just as we want it.
+
+The definitions made in the C code are not automatically exported from
+a module.  You need to explicitely list the ones you want to export in
address@hidden statements or with the @code{:export} option of
address@hidden
 
+There is also a way to manipulate the module system from C but only
+Scheme files can be autoloaded.  Thus, we recommend that you define
+your modules in Scheme.
 
 @page
 @node Reporting Bugs



reply via email to

[Prev in Thread] Current Thread [Next in Thread]