File: repl.texi

package info (click to toggle)
librep 0.17-13
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,648 kB
  • ctags: 2,969
  • sloc: ansic: 32,770; lisp: 12,399; sh: 7,971; makefile: 515; sed: 93
file content (176 lines) | stat: -rw-r--r-- 5,655 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
@c The REPL -*-Texinfo-*-

@chapter The REPL
@cindex The REPL
@cindex Read-eval-print loop

When you invoke the stand-alone librep interpreter without giving it a
script to execute the system is started in interactive mode. This
means that the @dfn{REPL} is entered---the read-eval-print loop.

The REPL works as its name suggests. It reads Lisp forms from the
console, evaluates them, and then prints the result back to the
console. Here is an example REPL session:

@lisp
user> (+ 1 1)
2
user> (cons 'a 'b)
(a . b)
@end lisp

@noindent
The @samp{user>} string is the prompt that the REPL prints when it is
waiting for an input form. This form may span several lines, e.g.:

@lisp
user> (cons 'a
'b)
(a . b)
@end lisp

@noindent
The prompt above contains the string @samp{user}. This is the name of
the module that the form will be evaluated in (@pxref{Modules}).

As well as allowing arbitrary Lisp forms to be entered and evaluated,
the REPL provides a rich set of meta-commands, these are used to
configure and inspect the state of the system, as well as providing
convenient shortcuts for common operations.

A meta-command is differentiated from a normal Lisp form by preceding
it with a comma (@samp{,}) character. The name of the command should
follow the comma, with any argument forms after that. Note that unlike
normal Lisp forms, no parentheses are used to mark the command
application.

For example the @code{whereis} meta-command searches all loaded modules
for those exporting a particular symbol. It might be used as follows:

@example
user> ,whereis string-match
string-match is exported by: rep.regexp
@end example

@noindent
The following table lists all currently supported meta-commands:

@table @code
@item access @var{struct} @dots{}
Add the modules named @var{struct} @dots{} to the list of structures
whose exported definitions may be accessed by the current module (using
the @code{structure-ref} special form).

@item accessible
Print the names of the modules whose contents may be accessed using the
@code{structure-ref} form from the current module.

@item apropos "@var{regexp}"
Print the definitions in the scope of the current module whose names
match the regular expression @var{regexp}.

@item bindings
Print all bindings in the current module.

@item collect
Run the garbage collector.

@item compile [@var{struct} @dots{}]
Compile any uncompiled functions in the modules named @var{struct}
@dots{}. If no named modules are given, use the current module.

@item compile-proc @var{procedure} @dots{}
Compile the functions called @var{procedure} @dots{} in the current
module.

@item describe @var{symbol}
Look for documentation describing the current meaning of @var{symbol},
if any is found, print it.

@item dis @var{form}
Disassemble the bytecode form or compiled function that is the result
of evaluating @var{form}.

@item expand @var{form}
Print @var{form} with any outermost macro calls recursively expanded.

@item exports
Print the names of the variables exported from the current module.

@item help
List all REPL commands.

@item imports
Print the names of the modules imported by the current module.

@item in @var{struct} [@var{form}]
If @var{form} is given, temporarily switch to the module called
@var{struct}, evaluate @var{form} printing the result, then switch back
to the original module.

If @var{form} isn't given, simply switch the current module to be
@var{struct}.

@item interfaces
Print all defined module interfaces, and their definitions.

@item load @var{struct} @dots{}
Attempt to load the module called @var{struct}.

@item load-file "@var{filename}" @dots{}
Load the file of Lisp forms called @var{filename}.

@item locate @var{symbol}
Recursively scan from the current module for the module providing the
binding of @var{symbol}. 

@item new @var{struct}
Create a new module called @var{struct}, and set it as the current
module. It will import the @code{rep.module-system} module, but nothing
else (i.e. no actual language).

@item open @var{struct} @dots{}
Import the modules called @var{struct} @dots{} to the current module.
This is analogous to the @code{open} clause in the configuration form
of the module's definition.

@item profile @var{form}
Evaluate @var{form}, recording information about the frequency and
duration of the calls it makes to subroutines (and the calls they make,
and so on). This information is tabulated and printed after the
evaluation has finished.

@item quit
Terminate the Lisp interpreter.

@item reload @var{struct} @dots{}
Reload the modules called @var{struct} @dots{}. If modules of these
names had previously been loaded, they will be deallocated when there
are no remaining references to them.

Note that importing the interface of one module into another does not
create object references between the two modules (the references are
purely symbolic). However, each closure (i.e. function) created in a
module does contain a reference to the module it was created in.

@item step @var{form}
Evaluate @var{form} in single-step mode (using the debugger).

@item structures
Print the names of all currently defined modules.

@item time @var{form}
Evaluate the form @var{form}, print the result and the time it took to
perform the evaluation.

@item unload @var{struct} @dots{}
Attempt to unload the modules called @var{struct} @dots{}. As with
reloading, unloading a module only removes the link between the module
name and the module body. Only once no more references exist to
the module body will it be freed.

@item whereis @var{symbol}
Scan all loaded modules for those that export a binding of
@var{symbol}, and print the results.
@end table