To initialize Guile, use this function:
exit (0)
;
scm_boot_guile
never returns. If you want some other exit value,
have main_func call exit itself.
scm_boot_guile
arranges for the Scheme command-line
function to return the strings given by argc and argv. If
main_func modifies argc or argv, it should call
scm_set_program_arguments
with the final list, so Scheme code
will know which arguments have been processed.
scm_boot_guile
establishes a catch-all error handler which prints
an error message and exits the process. This means that Guile exits in
a coherent way if a system error occurs and the user isn't prepared to
handle it. If the user doesn't like this behavior, they can establish
their own universal catcher in main_func to shadow this one.
Why must the caller do all the real work from main_func? Guile's
garbage collector assumes that all local variables which reference
Scheme objects will be above scm_boot_guile
's stack frame on the
stack. If you try to manipulate Scheme objects after this function
returns, it's the luck of the draw whether Guile's storage manager will
be able to find the objects you allocate. So, scm_boot_guile
function exits, rather than returning, to discourage you from making
that mistake.
One common way to use Guile is to write a set of C functions which
perform some useful task, make them callable from Scheme, and then link
the program with Guile. This yields a Scheme interpreter just like
guile
, but augmented with extra functions for some specific
application -- a special-purpose scripting language.
In this situation, the application should probably process its command-line arguments in the same manner as the stock Guile interpreter. To make that straightforward, Guile provides this function:
guile
executable. This includes loading the normal Guile initialization
files, interacting with the user or running any scripts or expressions
specified by -s
or -e
options, and then exiting.
See section Invoking Guile, for more details.
Since this function does not return, you must do all application-specific initialization before calling this function.
If you do not use this function to start Guile, you are responsible for making sure Guile's usual initialization files, `init.scm' and `ice-9/boot-9.scm', get loaded. This will change soon.
Go to the first, previous, next, last section, table of contents.