~ubuntu-branches/ubuntu/utopic/critcl/utopic

« back to all changes in this revision

Viewing changes to doc/include/using_eload.inc

  • Committer: Package Import Robot
  • Author(s): Andrew Shadura
  • Date: 2013-05-11 00:08:06 UTC
  • Revision ID: package-import@ubuntu.com-20130511000806-7hq1zc3fnn0gat79
Tags: upstream-3.1.9
ImportĀ upstreamĀ versionĀ 3.1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
[subsection {Unlazy Packages}]
 
2
 
 
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.
 
9
 
 
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.
 
15
 
 
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
 
18
[cmd critcl::load].
 
19
 
 
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.
 
23
 
 
24
[example {
 
25
    package require critcl
 
26
 
 
27
    ... Declare C procedures, commands, etc.
 
28
 
 
29
    critcl::load ; # Force build and loading.
 
30
}]
 
31
 
 
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
 
34
 
 
35
[example {
 
36
    package require critcl
 
37
 
 
38
    ... Declare C procedures, commands, etc.
 
39
 
 
40
    critcl::load ; # Force build and loading.
 
41
 
 
42
    ... More declarations of C code, ...
 
43
    critcl::code { ... }
 
44
}]
 
45
 
 
46
will result in an error. The only package-related commands still
 
47
allowed are
 
48
 
 
49
[list_begin enumerated]
 
50
[enum] [cmd critcl::done]
 
51
[enum] [cmd critcl::failed]
 
52
[enum] [cmd critcl::load]
 
53
[list_end]
 
54
 
 
55
as these only query information, namely the build status, and are
 
56
protected against multiple calls.