1
[subsection {Unlazy Packages}]
3
By default critcl is a bit inconsistent between modes "compile & run"
4
and "generate package". The result of the latter is a standard Tcl
5
package which loads and sources all of its files immediately when it
6
is required. Whereas "compile & run" defers actual compilation,
7
linking, and loading until the first time one of the declared commands
8
is actually used, making this very lazy.
10
[para] This behaviour can be quite unwanted if Tcl companion files, or
11
other users of the C commands use introspection to determine the
12
features they have available. Just using [lb][cmd {info commands}][rb]
13
doesn't cut it, the [var auto_index] array has to be checked as well,
14
making things quite inconvenient for the users.
16
[para] To fix this issue at the source, instead of in each user, be it
17
inside of the package itself, or other packages, we have the command
20
Used as the last command in a [file .critcl] file it forces the
21
compile, link, and load trinity, ensuring that all C commands are
22
available immediately.
25
package require critcl
27
... Declare C procedures, commands, etc.
29
critcl::load ; # Force build and loading.
32
Note that is not allowed, nor possible to use critcl commands
33
declaring anything after [cmd critcl::load] has been called. I.e., code like
36
package require critcl
38
... Declare C procedures, commands, etc.
40
critcl::load ; # Force build and loading.
42
... More declarations of C code, ...
46
will result in an error. The only package-related commands still
49
[list_begin enumerated]
50
[enum] [cmd critcl::done]
51
[enum] [cmd critcl::failed]
52
[enum] [cmd critcl::load]
55
as these only query information, namely the build status, and are
56
protected against multiple calls.