mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
* scripts/README, scripts/hello.scm, safe/untrusted.scm,
safe/evil.scm, safe/README, modules/README, modules/main, modules/module-0.scm, modules/module-1.scm, modules/module-2.scm: Minor cleanup. * README: Added intro stuff, restructured a bit. * box-dynamic/README, box-module/README, box/README: Cleanup and restructuring. * box-dynamic-module/box-mixed.scm: New file, demonstrating usage of extension library functionality, but without exporting procedures from the library. Thanks to Thomas Wawrzinek for the idea and example code! * box-dynamic-module/box-module.scm: Add comments, export make-box, box-ref, box-set!. * box-dynamic-module/README: Integrate new module (box-mixed), restructure and cleanup a bit.
This commit is contained in:
parent
4927dd283b
commit
673509f84f
21 changed files with 236 additions and 60 deletions
|
@ -1,3 +1,27 @@
|
||||||
|
2001-06-14 Martin Grabmueller <mgrabmue@cs.tu-berlin.de>
|
||||||
|
|
||||||
|
* scripts/README, scripts/hello.scm, safe/untrusted.scm,
|
||||||
|
safe/evil.scm, safe/README, modules/README, modules/main,
|
||||||
|
modules/module-0.scm, modules/module-1.scm, modules/module-2.scm:
|
||||||
|
Minor cleanup.
|
||||||
|
|
||||||
|
* README: Added intro stuff, restructured a bit.
|
||||||
|
|
||||||
|
* box-dynamic/README, box-module/README, box/README: Cleanup and
|
||||||
|
restructuring.
|
||||||
|
|
||||||
|
* box-dynamic-module/box-mixed.scm: New file, demonstrating usage
|
||||||
|
of extension library functionality, but without exporting
|
||||||
|
procedures from the library.
|
||||||
|
|
||||||
|
Thanks to Thomas Wawrzinek for the idea and example code!
|
||||||
|
|
||||||
|
* box-dynamic-module/box-module.scm: Add comments, export
|
||||||
|
make-box, box-ref, box-set!.
|
||||||
|
|
||||||
|
* box-dynamic-module/README: Integrate new module (box-mixed),
|
||||||
|
restructure and cleanup a bit.
|
||||||
|
|
||||||
2001-06-06 Martin Grabmueller <mgrabmue@cs.tu-berlin.de>
|
2001-06-06 Martin Grabmueller <mgrabmue@cs.tu-berlin.de>
|
||||||
|
|
||||||
* box-dynamic-module/box-module.scm: New file.
|
* box-dynamic-module/box-module.scm: New file.
|
||||||
|
|
|
@ -1,12 +1,28 @@
|
||||||
-*- text -*-
|
-*- outline -*-
|
||||||
|
|
||||||
|
* Overview
|
||||||
|
|
||||||
This directory contains examples illustrating various aspects of Guile
|
This directory contains examples illustrating various aspects of Guile
|
||||||
programming.
|
programming.
|
||||||
|
|
||||||
|
If you plan writing Scheme programs, have a look at the `scripts'
|
||||||
|
directory. To learn more about Guile modules, check out the `modules'
|
||||||
|
directory, and maybe the `box-module' and `box-dynamic-module'
|
||||||
|
directories, if you are into C programming or shared libraries,
|
||||||
|
respectively. The `safe' directory contains examples for evaluation
|
||||||
|
Scheme code in controlled environments (sandboxing). The directories
|
||||||
|
`box', `box-module', `box-dynamic' and `box-dynamic-module' are
|
||||||
|
interesting if you plan writing Guile extensions.
|
||||||
|
|
||||||
See the README files in the subdirectories for details.
|
See the README files in the subdirectories for details.
|
||||||
|
|
||||||
|
|
||||||
|
* Included Examples
|
||||||
|
|
||||||
scripts Examples for writing simple scripts in Guile Scheme.
|
scripts Examples for writing simple scripts in Guile Scheme.
|
||||||
|
|
||||||
box Example for extending Guile with a new data type.
|
box Example for extending Guile with a new data type.
|
||||||
|
|
||||||
box-module Similar to `box', but defines new procedures in a
|
box-module Similar to `box', but defines new procedures in a
|
||||||
named module.
|
named module.
|
||||||
box-dynamic Implements the box type in a dynamically loadable
|
box-dynamic Implements the box type in a dynamically loadable
|
||||||
|
@ -14,6 +30,7 @@ box-dynamic Implements the box type in a dynamically loadable
|
||||||
box-dynamic-module Combination of `box-module' and `box-dynamic':
|
box-dynamic-module Combination of `box-module' and `box-dynamic':
|
||||||
Implements the `box' type in a shared library and
|
Implements the `box' type in a shared library and
|
||||||
defines the procedures in a Guile module.
|
defines the procedures in a Guile module.
|
||||||
modules Examples for writing and using Guile modules.
|
|
||||||
safe Examples for creating and using safe environments.
|
|
||||||
|
|
||||||
|
modules Examples for writing and using Guile modules.
|
||||||
|
|
||||||
|
safe Examples for creating and using safe environments.
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
## to the Free Software Foundation, Inc., 59 Temple Place, Suite
|
## to the Free Software Foundation, Inc., 59 Temple Place, Suite
|
||||||
## 330, Boston, MA 02111-1307 USA
|
## 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
EXTRA_DIST = README box.c box-module.scm
|
EXTRA_DIST = README box.c box-module.scm box-mixed.scm
|
||||||
|
|
||||||
CFLAGS=`guile-config compile`
|
CFLAGS=`guile-config compile`
|
||||||
LIBS=`guile-config link`
|
LIBS=`guile-config link`
|
||||||
|
|
|
@ -1,35 +1,44 @@
|
||||||
-*- text -*-
|
-*- outline -*-
|
||||||
|
|
||||||
|
* Overview
|
||||||
|
|
||||||
This directory includes an example program for extending Guile with a
|
This directory includes an example program for extending Guile with a
|
||||||
new (and even useful) data type, putting it into a shared library, so it
|
new (and even useful) data type, putting it into a shared library, so it
|
||||||
can be called from an unmodified guile interpreter. Further, the shared
|
can be called from an unmodified guile interpreter. Further, the shared
|
||||||
library defines a new guile module.
|
library defines a new guile module.
|
||||||
|
|
||||||
|
|
||||||
|
* Build Instructions
|
||||||
|
|
||||||
To build the example, simply type
|
To build the example, simply type
|
||||||
|
|
||||||
make libbox-module
|
make libbox-module
|
||||||
|
|
||||||
in this directory.
|
in this directory.
|
||||||
|
|
||||||
|
|
||||||
|
* The Box Data Type
|
||||||
|
|
||||||
A box is simply an object for storing one other object in. It can be
|
A box is simply an object for storing one other object in. It can be
|
||||||
used for passing parameters by reference, for example. You simply
|
used for passing parameters by reference, for example. You simply
|
||||||
store an object into a box, pass it to another procedure which can
|
store an object into a box, pass it to another procedure which can
|
||||||
store a new object into it and thus return a value via the box.
|
store a new object into it and thus return a value via the box.
|
||||||
|
|
||||||
|
|
||||||
|
** Usage
|
||||||
|
|
||||||
Box objects are created with `make-box', set with `box-set!' and
|
Box objects are created with `make-box', set with `box-set!' and
|
||||||
examined with `box-ref'. Note that these procedures are placed in a
|
examined with `box-ref'. Note that these procedures are placed in a
|
||||||
module called (box-module) and can thus only be accessed after using
|
module called (box-module) and can thus only be accessed after using
|
||||||
this module. See the following example session for usage details:
|
this module. See the following example session for usage details.
|
||||||
|
|
||||||
|
|
||||||
|
** The Module (box-module)
|
||||||
|
|
||||||
Extend your LD_LIBRARY_PATH variable (or equivalent) to include . and
|
Extend your LD_LIBRARY_PATH variable (or equivalent) to include . and
|
||||||
.libs and make sure that your current working directory is the one
|
.libs and make sure that your current working directory is the one
|
||||||
this file is contained in.
|
this file is contained in.
|
||||||
|
|
||||||
If you like this example so much that you want to have it available
|
|
||||||
for normal usage, install the dynamic libraries in the .libs directory
|
|
||||||
to the directory $(prefix)/lib and the scheme file `box-module.scm' in
|
|
||||||
a directory in your GUILE_LOAD_PATH.
|
|
||||||
|
|
||||||
$ guile
|
$ guile
|
||||||
guile> (use-modules (box-module))
|
guile> (use-modules (box-module))
|
||||||
guile> (define b (make-box))
|
guile> (define b (make-box))
|
||||||
|
@ -42,3 +51,27 @@ guile> (box-ref b)
|
||||||
(list of values)
|
(list of values)
|
||||||
guile> (quit)
|
guile> (quit)
|
||||||
$
|
$
|
||||||
|
|
||||||
|
|
||||||
|
** The Module (box-mixed)
|
||||||
|
|
||||||
|
The following example uses the module (box-mixed), also included in
|
||||||
|
this directory. It uses the shared library libbox-module like the
|
||||||
|
module (box-module) above, but does not export the procedures from
|
||||||
|
that module. It only implements some procedures for dealing with box
|
||||||
|
objects.
|
||||||
|
|
||||||
|
$ guile
|
||||||
|
guile> (use-modules (box-mixed))
|
||||||
|
guile> (define bl (make-box-list 1 2 3))
|
||||||
|
guile> bl
|
||||||
|
(#<box 1> #<box 2> #<box 3>)
|
||||||
|
guile> (box-map (lambda (el) (make-box-list (list el))) bl)
|
||||||
|
(#<box (#<box (1)>)> #<box (#<box (2)>)> #<box (#<box (3)>)>)
|
||||||
|
guile> (quit)
|
||||||
|
$
|
||||||
|
|
||||||
|
If you like this example so much that you want to have it available
|
||||||
|
for normal usage, install the dynamic libraries in the .libs directory
|
||||||
|
to the directory $(prefix)/lib and the scheme file `box-module.scm' in
|
||||||
|
a directory in your GUILE_LOAD_PATH.
|
||||||
|
|
44
examples/box-dynamic-module/box-mixed.scm
Normal file
44
examples/box-dynamic-module/box-mixed.scm
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
;;; examples/box-dynamic-module/box-mixed.scm -- Scheme module using some
|
||||||
|
;;; functionality from the shared library libbox-module, but do not
|
||||||
|
;;; export procedures from the module.
|
||||||
|
|
||||||
|
;;; Commentary:
|
||||||
|
|
||||||
|
;;; This is the Scheme module box-mixed. It uses some functionality
|
||||||
|
;;; from the shared library libbox-module, but does not export it.
|
||||||
|
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
|
;;; Author: Thomas Wawrzinek
|
||||||
|
;;; Date: 2001-06-08
|
||||||
|
;;; Changed: 2001-06-14 by martin, some commenting, cleanup and integration.
|
||||||
|
|
||||||
|
(define-module (box-mixed))
|
||||||
|
|
||||||
|
;; First, load the library.
|
||||||
|
;;
|
||||||
|
(load-extension "libbox-module" "scm_init_box")
|
||||||
|
|
||||||
|
;; Create a list of boxes, each containing one element from ARGS.
|
||||||
|
;;
|
||||||
|
(define (make-box-list . args)
|
||||||
|
(map (lambda (el)
|
||||||
|
(let ((b (make-box)))
|
||||||
|
(box-set! b el) b))
|
||||||
|
args))
|
||||||
|
|
||||||
|
;; Map the procedure FUNC over all elements of LST, which must be a
|
||||||
|
;; list of boxes. The result is a list of freshly allocated boxes,
|
||||||
|
;; each containing the result of an application of FUNC.
|
||||||
|
(define (box-map func lst)
|
||||||
|
(map (lambda (el)
|
||||||
|
(let ((b (make-box)))
|
||||||
|
(box-set! b (func (box-ref el)))
|
||||||
|
b))
|
||||||
|
lst))
|
||||||
|
|
||||||
|
;; Export the procedures, so that they can be used by others.
|
||||||
|
;;
|
||||||
|
(export make-box-list box-map)
|
||||||
|
|
||||||
|
;;; End of file.
|
|
@ -1,5 +1,5 @@
|
||||||
;;; examples/box-dynamic-module/box-module.scm -- Scheme part of the
|
;;; examples/box-dynamic-module/box-module.scm -- Scheme module exporting
|
||||||
;;; dynamic module (box-module)
|
;;; some functionality from the shared library libbox-module.
|
||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
|
|
||||||
|
@ -14,4 +14,12 @@
|
||||||
|
|
||||||
(define-module (box-module))
|
(define-module (box-module))
|
||||||
|
|
||||||
|
;; First, load the library.
|
||||||
|
;;
|
||||||
(load-extension "libbox-module" "scm_init_box")
|
(load-extension "libbox-module" "scm_init_box")
|
||||||
|
|
||||||
|
;; Then export the procedures which should be visible to module users.
|
||||||
|
;;
|
||||||
|
(export make-box box-ref box-set!)
|
||||||
|
|
||||||
|
;;; End of file.
|
||||||
|
|
|
@ -107,14 +107,13 @@ box_set_x (SCM b, SCM value)
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
|
||||||
/* Create and initialize the new smob type, and register the
|
/* This is the function which must be given to `load-extension' as the
|
||||||
primitives withe the interpreter library.
|
second argument. In this example, the Scheme file box-module.scm
|
||||||
|
(or box-mixed.scm) is responsible for doing the load-extension
|
||||||
This function must be declared a bit different from the example in
|
call. The Scheme modules are also responsible for placing the
|
||||||
the ../box directory, because it will be called by
|
procedure definitions in the correct module. */
|
||||||
`scm_c_define_module', called from below. */
|
void
|
||||||
static void
|
scm_init_box ()
|
||||||
init_box_type (void * unused)
|
|
||||||
{
|
{
|
||||||
scm_tc16_box = scm_make_smob_type ("box", 0);
|
scm_tc16_box = scm_make_smob_type ("box", 0);
|
||||||
scm_set_smob_mark (scm_tc16_box, mark_box);
|
scm_set_smob_mark (scm_tc16_box, mark_box);
|
||||||
|
@ -123,26 +122,6 @@ init_box_type (void * unused)
|
||||||
scm_c_define_gsubr ("make-box", 0, 0, 0, make_box);
|
scm_c_define_gsubr ("make-box", 0, 0, 0, make_box);
|
||||||
scm_c_define_gsubr ("box-set!", 2, 0, 0, box_set_x);
|
scm_c_define_gsubr ("box-set!", 2, 0, 0, box_set_x);
|
||||||
scm_c_define_gsubr ("box-ref", 1, 0, 0, box_ref);
|
scm_c_define_gsubr ("box-ref", 1, 0, 0, box_ref);
|
||||||
|
|
||||||
/* This is new too: Since the procedures are now in a module, we
|
|
||||||
have to explicitly export them before they can be used. */
|
|
||||||
scm_c_export ("make-box", "box-set!", "box-ref", NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is the function which must be given to `load-extension' as the
|
|
||||||
second argument. It will initialize the shared, library, but will
|
|
||||||
place the definitions in a module called (box-module), so that an
|
|
||||||
additional (use-modules (box-module)) is needed to make them
|
|
||||||
accessible. In this example, the Scheme file box-module.scm is
|
|
||||||
responsible for doing the load-extension call. */
|
|
||||||
void
|
|
||||||
scm_init_box ()
|
|
||||||
{
|
|
||||||
/* Unlike the example in ../box, init_box_type is not called
|
|
||||||
directly, but by scm_c_define_module, which will create a module
|
|
||||||
named (box-module) and make this module current while called
|
|
||||||
init_box_type, thus placing the definitions into that module. */
|
|
||||||
scm_c_define_module ("box-module", init_box_type, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file. */
|
/* End of file. */
|
||||||
|
|
|
@ -1,20 +1,31 @@
|
||||||
-*- text -*-
|
-*- outline -*-
|
||||||
|
|
||||||
|
* Overview
|
||||||
|
|
||||||
This directory includes an example program for extending Guile with a
|
This directory includes an example program for extending Guile with a
|
||||||
new (and even useful) data type, putting it into a shared library, so it
|
new (and even useful) data type, putting it into a shared library, so it
|
||||||
can be called from an unmodified guile interpreter.
|
can be called from an unmodified guile interpreter.
|
||||||
|
|
||||||
|
|
||||||
|
* Build Instructions
|
||||||
|
|
||||||
To build the example, simply type
|
To build the example, simply type
|
||||||
|
|
||||||
make libbox
|
make libbox
|
||||||
|
|
||||||
in this directory.
|
in this directory.
|
||||||
|
|
||||||
|
|
||||||
|
* The Box Data Type
|
||||||
|
|
||||||
A box is simply an object for storing one other object in. It can be
|
A box is simply an object for storing one other object in. It can be
|
||||||
used for passing parameters by reference, for example. You simply
|
used for passing parameters by reference, for example. You simply
|
||||||
store an object into a box, pass it to another procedure which can
|
store an object into a box, pass it to another procedure which can
|
||||||
store a new object into it and thus return a value via the box.
|
store a new object into it and thus return a value via the box.
|
||||||
|
|
||||||
|
|
||||||
|
** Usage
|
||||||
|
|
||||||
Box objects are created with `make-box', set with `box-set!' and
|
Box objects are created with `make-box', set with `box-set!' and
|
||||||
examined with `box-ref'. Note that these procedures are placed in a
|
examined with `box-ref'. Note that these procedures are placed in a
|
||||||
module called (box-module) and can thus only be accessed after using
|
module called (box-module) and can thus only be accessed after using
|
||||||
|
@ -23,9 +34,8 @@ this module. See the following example session for usage details:
|
||||||
Extend your LD_LIBRARY_PATH variable (or equivalent) to include . and
|
Extend your LD_LIBRARY_PATH variable (or equivalent) to include . and
|
||||||
.libs
|
.libs
|
||||||
|
|
||||||
If you like this example so much that you want to have it available
|
|
||||||
for normal usage, install the dynamic libraries in the .libs directory
|
** Example Session
|
||||||
to the directory $(prefix)/lib
|
|
||||||
|
|
||||||
$ ./guile
|
$ ./guile
|
||||||
guile> (load-extension "libbox" "scm_init_box")
|
guile> (load-extension "libbox" "scm_init_box")
|
||||||
|
@ -39,3 +49,10 @@ guile> (box-ref b)
|
||||||
(list of values)
|
(list of values)
|
||||||
guile> (quit)
|
guile> (quit)
|
||||||
$
|
$
|
||||||
|
|
||||||
|
|
||||||
|
* Module Installation
|
||||||
|
|
||||||
|
If you like this example so much that you want to have it available
|
||||||
|
for normal usage, install the dynamic libraries in the .libs directory
|
||||||
|
to the directory $(prefix)/lib
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
-*- text -*-
|
-*- outline -*-
|
||||||
|
|
||||||
|
* Overview
|
||||||
|
|
||||||
This directory includes an example program for extending Guile with a
|
This directory includes an example program for extending Guile with a
|
||||||
new (and even useful) data type.
|
new (and even useful) data type.
|
||||||
|
@ -9,6 +11,9 @@ interpreter in this directory will place all defined primitive
|
||||||
procedures in a module called (box-module). That means that this
|
procedures in a module called (box-module). That means that this
|
||||||
module must be used before the primitives can be accessed.
|
module must be used before the primitives can be accessed.
|
||||||
|
|
||||||
|
|
||||||
|
* Build Instructions
|
||||||
|
|
||||||
To build the example, simply type
|
To build the example, simply type
|
||||||
|
|
||||||
make box
|
make box
|
||||||
|
@ -18,16 +23,25 @@ in this directory.
|
||||||
The resulting `box' program is a Guile interpreter which has one
|
The resulting `box' program is a Guile interpreter which has one
|
||||||
additional data type called `box'.
|
additional data type called `box'.
|
||||||
|
|
||||||
|
|
||||||
|
* The Box Data Type
|
||||||
|
|
||||||
A box is simply an object for storing one other object in. It can be
|
A box is simply an object for storing one other object in. It can be
|
||||||
used for passing parameters by reference, for example. You simply
|
used for passing parameters by reference, for example. You simply
|
||||||
store an object into a box, pass it to another procedure which can
|
store an object into a box, pass it to another procedure which can
|
||||||
store a new object into it and thus return a value via the box.
|
store a new object into it and thus return a value via the box.
|
||||||
|
|
||||||
|
|
||||||
|
** Usage
|
||||||
|
|
||||||
Box objects are created with `make-box', set with `box-set!' and
|
Box objects are created with `make-box', set with `box-set!' and
|
||||||
examined with `box-ref'. Note that these procedures are placed in a
|
examined with `box-ref'. Note that these procedures are placed in a
|
||||||
module called (box-module) and can thus only be accessed after using
|
module called (box-module) and can thus only be accessed after using
|
||||||
this module. See the following example session for usage details:
|
this module. See the following example session for usage details:
|
||||||
|
|
||||||
|
|
||||||
|
** Example Session
|
||||||
|
|
||||||
$ ./box
|
$ ./box
|
||||||
guile> (use-modules (box-module))
|
guile> (use-modules (box-module))
|
||||||
guile> (define b (make-box))
|
guile> (define b (make-box))
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
-*- text -*-
|
-*- outline -*-
|
||||||
|
|
||||||
|
* Overview
|
||||||
|
|
||||||
This directory includes an example program for extending Guile with a
|
This directory includes an example program for extending Guile with a
|
||||||
new (and even useful) data type.
|
new (and even useful) data type.
|
||||||
|
|
||||||
|
|
||||||
|
* Build Instructions
|
||||||
|
|
||||||
To build the example, simply type
|
To build the example, simply type
|
||||||
|
|
||||||
make box
|
make box
|
||||||
|
@ -12,15 +17,24 @@ in this directory.
|
||||||
The resulting `box' program is a Guile interpreter which has one
|
The resulting `box' program is a Guile interpreter which has one
|
||||||
additional data type called `box'.
|
additional data type called `box'.
|
||||||
|
|
||||||
|
|
||||||
|
* The Box Data Type
|
||||||
|
|
||||||
A box is simply an object for storing one other object in. It can be
|
A box is simply an object for storing one other object in. It can be
|
||||||
used for passing parameters by reference, for example. You simply
|
used for passing parameters by reference, for example. You simply
|
||||||
store an object into a box, pass it to another procedure which can
|
store an object into a box, pass it to another procedure which can
|
||||||
store a new object into it and thus return a value via the box.
|
store a new object into it and thus return a value via the box.
|
||||||
|
|
||||||
|
|
||||||
|
** Usage
|
||||||
|
|
||||||
Box objects are created with `make-box', set with `box-set!' and
|
Box objects are created with `make-box', set with `box-set!' and
|
||||||
examined with `box-ref'. See the following example session for usage
|
examined with `box-ref'. See the following example session for usage
|
||||||
details:
|
details:
|
||||||
|
|
||||||
|
|
||||||
|
** Example Session
|
||||||
|
|
||||||
$ ./box
|
$ ./box
|
||||||
guile> (define b (make-box))
|
guile> (define b (make-box))
|
||||||
guile> b
|
guile> b
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
-*- text -*-
|
-*- outline -*-
|
||||||
|
|
||||||
|
* Overview
|
||||||
|
|
||||||
This directory includes examples which show how to write and use Guile
|
This directory includes examples which show how to write and use Guile
|
||||||
modules in Scheme programs.
|
modules in Scheme programs.
|
||||||
|
@ -7,7 +9,11 @@ The descriptions below assume that you have a working copy of Guile
|
||||||
installed and available with the standard installation prefix
|
installed and available with the standard installation prefix
|
||||||
`/usr/local'.
|
`/usr/local'.
|
||||||
|
|
||||||
main:
|
|
||||||
|
* Included Examples
|
||||||
|
|
||||||
|
|
||||||
|
** main
|
||||||
|
|
||||||
The main program, which uses the modules described below to perform
|
The main program, which uses the modules described below to perform
|
||||||
some actions. Module usage and selective importing as well as
|
some actions. Module usage and selective importing as well as
|
||||||
|
@ -19,7 +25,7 @@ main:
|
||||||
|
|
||||||
guile -s main
|
guile -s main
|
||||||
|
|
||||||
module-0.scm, module-1.scm, module-2.scm:
|
** module-0.scm, module-1.scm, module-2.scm
|
||||||
|
|
||||||
Two modules which export several procedure, some of which have the
|
Two modules which export several procedure, some of which have the
|
||||||
same names (so that renaming/selection is required for proper
|
same names (so that renaming/selection is required for proper
|
||||||
|
|
|
@ -20,3 +20,5 @@
|
||||||
(define (bar)
|
(define (bar)
|
||||||
(display "module-0 bar")
|
(display "module-0 bar")
|
||||||
(newline))
|
(newline))
|
||||||
|
|
||||||
|
;;; End of file.
|
||||||
|
|
|
@ -20,3 +20,5 @@
|
||||||
(define (bar)
|
(define (bar)
|
||||||
(display "module-1 bar")
|
(display "module-1 bar")
|
||||||
(newline))
|
(newline))
|
||||||
|
|
||||||
|
;;; End of file.
|
||||||
|
|
|
@ -24,3 +24,5 @@
|
||||||
(define (braz)
|
(define (braz)
|
||||||
(display "module-2 braz")
|
(display "module-2 braz")
|
||||||
(newline))
|
(newline))
|
||||||
|
|
||||||
|
;;; End of file.
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
-*- text -*-
|
-*- outline -*-
|
||||||
|
|
||||||
|
* Overview
|
||||||
|
|
||||||
This directory includes examples which show how to create and use safe
|
This directory includes examples which show how to create and use safe
|
||||||
environments for safe (sand-boxed) execution of Scheme programs.
|
environments for safe (sand-boxed) execution of Scheme programs.
|
||||||
|
@ -12,7 +14,10 @@ The descriptions below assume that you have a working copy of Guile
|
||||||
installed and available with the standard installation prefix
|
installed and available with the standard installation prefix
|
||||||
`/usr/local'.
|
`/usr/local'.
|
||||||
|
|
||||||
safe:
|
* Included Examples
|
||||||
|
|
||||||
|
|
||||||
|
** safe
|
||||||
|
|
||||||
The main program, which executes the Scheme code in a file given on
|
The main program, which executes the Scheme code in a file given on
|
||||||
the command line in a safe environment. The following command will
|
the command line in a safe environment. The following command will
|
||||||
|
@ -24,12 +29,12 @@ safe:
|
||||||
|
|
||||||
guile -s safe untrusted.scm
|
guile -s safe untrusted.scm
|
||||||
|
|
||||||
untrusted.scm:
|
** untrusted.scm
|
||||||
|
|
||||||
This file contains some Scheme code, which will be executed in a
|
This file contains some Scheme code, which will be executed in a
|
||||||
safe environment by the `safe' script.
|
safe environment by the `safe' script.
|
||||||
|
|
||||||
evil.scm
|
** evil.scm
|
||||||
|
|
||||||
This file also contains Scheme code, but it tries to do evil things.
|
This file also contains Scheme code, but it tries to do evil things.
|
||||||
Evaluating this with the `safe' script will abort on those evil
|
Evaluating this with the `safe' script will abort on those evil
|
||||||
|
|
|
@ -23,3 +23,5 @@
|
||||||
(let lp ((ch (read-char passwd)))
|
(let lp ((ch (read-char passwd)))
|
||||||
(if (not (eof-object? ch))
|
(if (not (eof-object? ch))
|
||||||
(lp (read-char passwd))))
|
(lp (read-char passwd))))
|
||||||
|
|
||||||
|
;;; End of file.
|
||||||
|
|
|
@ -29,3 +29,5 @@
|
||||||
((= x 11))
|
((= x 11))
|
||||||
(display (fact x))
|
(display (fact x))
|
||||||
(newline))
|
(newline))
|
||||||
|
|
||||||
|
;;; End of file.
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
-*- text -*-
|
-*- outline -*-
|
||||||
|
|
||||||
|
* Overview
|
||||||
|
|
||||||
This directory includes examples which show how to write scripts using
|
This directory includes examples which show how to write scripts using
|
||||||
Guile.
|
Guile.
|
||||||
|
@ -7,13 +9,16 @@ The descriptions below assume that you have a working copy of Guile
|
||||||
installed and available with the standard installation prefix
|
installed and available with the standard installation prefix
|
||||||
`/usr/local'.
|
`/usr/local'.
|
||||||
|
|
||||||
simple-hello.scm:
|
* Included Examples
|
||||||
|
|
||||||
|
|
||||||
|
** simple-hello.scm
|
||||||
|
|
||||||
The simplest "Hello World!" program for Guile. Run it like this:
|
The simplest "Hello World!" program for Guile. Run it like this:
|
||||||
|
|
||||||
$ guile -s simple-hello.scm
|
$ guile -s simple-hello.scm
|
||||||
|
|
||||||
hello:
|
** hello
|
||||||
|
|
||||||
An advanced version of the script above, with command line handling
|
An advanced version of the script above, with command line handling
|
||||||
for the important options --help and --version. Run it like this:
|
for the important options --help and --version. Run it like this:
|
||||||
|
@ -24,7 +29,7 @@ hello:
|
||||||
|
|
||||||
guile -s hello
|
guile -s hello
|
||||||
|
|
||||||
fact:
|
** fact
|
||||||
|
|
||||||
Command-line factorial calculator. Run it like this:
|
Command-line factorial calculator. Run it like this:
|
||||||
|
|
||||||
|
|
|
@ -67,4 +67,3 @@
|
||||||
;; Local variables:
|
;; Local variables:
|
||||||
;; mode: scheme
|
;; mode: scheme
|
||||||
;; End:
|
;; End:
|
||||||
|
|
||||||
|
|
|
@ -55,4 +55,3 @@
|
||||||
;; Local variables:
|
;; Local variables:
|
||||||
;; mode: scheme
|
;; mode: scheme
|
||||||
;; End:
|
;; End:
|
||||||
|
|
||||||
|
|
|
@ -12,3 +12,5 @@
|
||||||
|
|
||||||
(display "Hello, World!")
|
(display "Hello, World!")
|
||||||
(newline)
|
(newline)
|
||||||
|
|
||||||
|
;;; End of file.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue