Loading¶
You can load more source code with load.
load
will search for the file to be loaded on IDIOLIB although extensions will be given priority over simple
files. You should not use a filename extension, eg. .idio
.
require / provide¶
load
is naïve and will blindly run everything in the source file
again.
You can prevent that happening by requiring a feature with
require which, if it hasn’t already seen the feature,
will call load
and check that the feature has been provide’d afterwards.
Importing¶
Finally, you can import a module (which uses
require
in turn). This changes the current module’s list of
imported modules and therefore the list of names it is able to see.
Some names clash, libc is an egregious example, so import wisely.
If a module exports a name you can commonly use it directly with
module/name
without incurring the name clashing costs of
import
. Unexported names cannot be accessed in this way.
Attention
This use of direct references to names is an artefact and
requires that someone somewhere has previously imported
module
so that its list of exported names can be
consulted.
One of the beneficiaries of this is libc
which is imported by
job-control
which is, in turn, imported during bootstrap. Now
all libc
exported names are accessible as libc/name
and we can avoid parameter-type conflicts between calling, say, the
external command, mkdir and the libc
function
libc/mkdir.
- function load filename¶
load Idio code from filename
- Param filename:
the filename to load from
- Type filename:
string
This is the module variant which handles changes to the current module and calls
load filename expression by expression
- Param filename:
the file to load
- Type filename:
string
The system will use the environment variable
IDIOLIB
to find filename.This is the load primitive.
- function load-handle handle¶
load Idio code from handle
- Param handle:
the handle to load from
- Type handle:
handle
This is the module variant which handles changes to the current module and calls
load expressions from handle expression by expression
- Param handle:
the handle to load from
- Type handle:
handle
This is the load-handle primitive.
- template provide feature¶
Update the list of required features with feature
- Param feature:
feature name
- Type feature:
symbol
- function require feature [subfeatures]¶
Load feature unless it has previous been successfully required. subfeatures are available to the loaded code as the dynamic variable require-subfeatures*.
- Param feature:
the name of the feature
- Type fmt:
symbol
- Param subfeatures:
names of subfeatures
- Type subfeatures:
list, optional
- Return:
#t or #f
The file to be loaded is
(symbol->string feature)
which must provide feature.
- template import [modules]¶
For each module in modules, require the module and update the list of imported modules.
- Param modules:
list of modules
- Type modules:
list
Last built at 2024-12-21T07:10:38Z+0000 from 62cca4c (dev) for Idio 0.3.b.6