aboutsummaryrefslogtreecommitdiff
path: root/jim_tcl.txt
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2010-11-03 16:14:51 +1000
committerSteve Bennett <steveb@workware.net.au>2010-11-03 18:57:02 +1000
commit298a9911f7a94c179829cc67d240d1b4cde7583b (patch)
treefeb27c5bc3960b5a3f3115ff3ae643d715559211 /jim_tcl.txt
parentbefc7190d7fdafd824c5a338362ab266761c6e75 (diff)
downloadjimtcl-298a9911f7a94c179829cc67d240d1b4cde7583b.zip
jimtcl-298a9911f7a94c179829cc67d240d1b4cde7583b.tar.gz
jimtcl-298a9911f7a94c179829cc67d240d1b4cde7583b.tar.bz2
Simplify and document [load]
Previously both load and package require would search the library path to find the file to load. Simplify this by requiring an explicit path with load and have package require search the path. Also, document load and how it is used by package require. Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim_tcl.txt')
-rw-r--r--jim_tcl.txt22
1 files changed, 20 insertions, 2 deletions
diff --git a/jim_tcl.txt b/jim_tcl.txt
index cd993f4..dfe6b4c 100644
--- a/jim_tcl.txt
+++ b/jim_tcl.txt
@@ -2697,6 +2697,16 @@ For example:
If the body invokes 'continue', no value is added for this iteration.
If the body invokes 'break', the loop ends and no more values are added.
+load
+~~~~
++*load* 'filename'+
+
+Loads the dynamic extension, *filename*. Generally the filename should have
+the extension '.so'. The initialisation function for the module must be based
+on the name of the file. For example loading +dir/hwaccess.so+ will invoke
+the initialisation function, +Jim_hwaccessInit+. Normally the 'load' command
+should not be used directly. Instead it is invoked automatically by 'package require'.
+
lrange
~~~~~~
+*lrange* 'list first last'+
@@ -2908,9 +2918,17 @@ as the first statement, although it is not required.
+*package require* 'name ?version?'*+
Searches for the package with the given *name* by examining each path
-in '$::auto_path' and trying to load '$path/$name.tcl'.
+in '$::auto_path' and trying to load '$path/$name.so' as a dynamic extension,
+or '$path/$name.tcl' as a script package.
+
+The first such file which is found is considered to provide the the package.
+(The version number is ignored).
+
+If '$name.so' exists, it is loaded with the 'load' command,
+otherwise if '$name.tcl' exists it is loaded with the 'source' command.
-If either file exists, it is loaded with 'source'.
+If 'load' or 'source' fails, 'package require' will fail immediately.
+No further attempt will be made to locate the file.
Typically '$::auto_path' contains the paths '.' and '/lib/jim'.