REBOL 3 Docs | Guide | Concepts | Functions | Datatypes | Errors |
TOC < Back Next > | Updated: 3-Aug-2010 Edit History |
Imports a module; locate, load, make, and setup its bindings.
Arguments:
module [word! file! url! module! block!]
Refinements:
/version
ver [tuple!] - Module must be this version or greater
/check
sum [binary!] - Module checksum as (checksum/secure of mold/flat)
/isolate - Force module to create and use its own non-shared global namespace
/only - Load and return module, but don't export to system
See also:
The import function is used to import modules into your runtime environment. For a full description see the modules: loading modules section of this documentation.
For example, you can write:
import 'mysql
and the system will search for the mysql module.
You can also use a filename or URL for the module identifier:
import %mysql.r import http://www.rebol.com/mods/mysql.r
When successful, the import function returns a module! datatype as its result.
This allows you to write:
mysql: import 'mysql
Now, the mysql variable can be used to refer to values within the mysql module.
For example the module value is used here to reference a function:
mysql/open-db %my-database.sql
See below for more.
Like the header needs field, the import function also lets you specify a version and a checksum.
These are all supported:
import/version mysql 1.2.3 import/check mysql #{A94A8FE5CCB19BA61C4C0873D391E987982FBBD3} import/version/check mysql 1.2.3 #{A94A8FE5CCB19BA61C4C0873D391E987982FBBD3}
The benefit of using the import function compared to the needs header field is that the arguments can be variables.
A basic example is:
mod: 'mysql import mod
Or, something like:
mod-list: [ mysql 1.2.3 db-gui 2.4.5 http-server 1.0.1 ] foreach [id ver] mod-list [ import/version id ver ]
TOC < Back Next > | REBOL.com - WIP Wiki | Feedback Admin |