~ chicken-core (master) /manual/Module (chicken load)
Trap1[[tags: manual]]2[[toc:]]34== Module (chicken load)56This module contains various procedures for loading code. Note that7the main procedure for loading code, {{load}}, is part of8[[Module scheme]]; the {{chicken load}} module only contains9''extensions'' to the standard.1011=== A note on loading of shared extension libraries1213The functionality of loading shared objects into the runtime is only14available on platforms that support dynamic loading of compiled15code. Currently Linux, BSD, Solaris, Windows (with Cygwin) and HP/UX16are supported. Loading source files works everywhere.1718=== load-relative1920<procedure>(load-relative FILE [ENVIRONMENT])</procedure>2122Similar to {{load}}, but loads {{FILE}} relative to the path23of the currently loaded file.2425=== load-noisily2627<procedure>(load-noisily FILE #!key ENVIRONMENT TIME PRINTER)</procedure>2829As {{load}} but the result(s) of each evaluated toplevel-expression30is written to standard output. If {{ENVIRONMENT}} is given and not {{#f}},31then each expression is evaluated using this environment. {{ENVIRONMENT}} may also be32a procedure used to evaluate each toplevel form. If {{TIME}} is given and not false, then33the execution time of each expression is shown (as with the {{time}} macro).34If {{PRINTER}} is given and not false, then each expression is35printed before evaluation by applying the expression to the value of this36argument, which should be a one-argument procedure.3738See also the [[#load-verbose|load-verbose]] parameter.3940=== load-library4142<procedure>(load-library UNIT [LIBRARYFILE])</procedure>4344On platforms that support dynamic loading, {{load-library}} loads45the compiled library unit {{UNIT}} (which should be a symbol). If the46string {{LIBRARYFILE}} is given, then the given shared library will47be loaded and the toplevel code of the specified unit will be executed.48If no {{LIBRARYFILE}} argument is given, then the libraries given in the49parameter {{dynamic-load-libraries}} are searched for the required unit.50If the unit is not found, an error is signaled.5152Note that {{LIBRARYFILE}} is considered relative to the {{dlopen(3)}}53search path by default. In order to use a file relative to the current54working directory, a relative or absolute pathname must be used, i.e.55{{LIBRARYFILE}} must contain at least one slash ({{"/"}}).5657=== require5859<procedure>(require ID ...)</procedure>6061If any of the named extension libraries {{ID}} are not already loaded62into the system, then {{require}} will look up the location of the63shared extension library and load it. If {{ID}} names a library-unit64of the base system, then it is loaded via {{load-library}}. If no65extension library is available for the given ID, then an attempt is66made to load the file {{ID.so}} or {{ID.scm}} (in that order) from one67of the following locations:6869* the current directory70* the current repository path (see {{repository-path}})7172Each {{ID}} should be a symbol.737475=== provide7677<procedure>(provide ID ...)</procedure>7879Registers the extension IDs {{ID ...}} as loaded. This is mainly80intended to provide aliases for certain library identifiers.818283=== provided?8485procedure: (provided? ID ...)8687Returns {{#t}} if extension with the IDs {{ID ...}} are currently88loaded, or {{#f}} otherwise.899091=== Tuning how code is loaded9293==== dynamic-load-libraries9495<parameter>(dynamic-load-libraries)</parameter>9697A list of strings containing shared libraries that should be checked98for explicitly loaded library units (this facility is not available on99all platforms). See {{load-library}}.100101102==== load-verbose103104<parameter>(load-verbose)</parameter>105106A boolean indicating whether loading of source files, compiled code107(if available) and compiled libraries should display a message.108109110==== set-dynamic-load-mode!111112<procedure>(set-dynamic-load-mode! MODELIST)</procedure>113114On systems that support dynamic loading of compiled code via the115{{dlopen(3)}} interface (for example Linux and Solaris), some options116can be specified to fine-tune the behaviour of the dynamic117linker. {{MODE}} should be a list of symbols (or a single symbol)118taken from the following set:119120; {{local}} : If {{local}} is given, then any C/C++ symbols defined in the dynamically loaded file are not available for subsequently loaded files and libraries. Use this if you have linked foreign code into your dynamically loadable file and if you don't want to export them (for example because you want to load another file that defines the same symbols).121; {{global}} : The default is {{global}}, which means all C/C++ symbols are available to code loaded at a later stage.122; {{now}} : If {{now}} is specified, all symbols are resolved immediately.123; {{lazy}} : Unresolved symbols are resolved as code from the file is executed. This is the default.124125Note that this procedure does not control the way Scheme variables are handled -126this facility is mainly of interest when accessing foreign code.127128129---130Previous: [[Module (chicken keyword)]]131132Next: [[Module (chicken locative)]]