| 1 |
@node Invoking ECL |
| 2 |
@section Entering and leaving @ecl{} |
| 3 |
|
| 4 |
@ecl{} is invoked by the command @code{ecl}. |
| 5 |
|
| 6 |
@example |
| 7 |
% ecl |
| 8 |
ECL (Embeddable Common-Lisp) 0.0e |
| 9 |
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya |
| 10 |
Copyright (C) 1993 Giuseppe Attardi |
| 11 |
Copyright (C) 2000 Juan J. Garcia-Ripoll |
| 12 |
Copyright (C) 2015 Daniel Kochmanski |
| 13 |
ECL is free software, and you are welcome to redistribute it |
| 14 |
under certain conditions; see file 'Copyright' for details. |
| 15 |
Type :h for Help. Top level. |
| 16 |
Top level in: #<process TOP-LEVEL>. |
| 17 |
> |
| 18 |
@end example |
| 19 |
|
| 20 |
When invoked, @ecl{} will print the banner and initialize the system. |
| 21 |
The number in the @ecl{} banner identifies the revision of |
| 22 |
@ecl{}. @code{0.0e} is the value of the function |
| 23 |
@code{lisp-implementation-version}. |
| 24 |
|
| 25 |
Unless user specifies @code{--norc} flag when invoking the @ecl{}, it |
| 26 |
will look for the initialization files @file{~/.ecl} and |
| 27 |
@file{~/.eclrc}. If he wants to load his own file from the current |
| 28 |
directory, then he should pass the file path to the @code{--load} |
| 29 |
parameter: |
| 30 |
@example |
| 31 |
% ecl --norc --load init.lisp |
| 32 |
@end example |
| 33 |
|
| 34 |
After the initialization, @ecl{} enters the @dfn{top-level loop} and |
| 35 |
prints the prompt `@code{>}'. |
| 36 |
|
| 37 |
@example |
| 38 |
Type :h for Help. Top level. |
| 39 |
> |
| 40 |
@end example |
| 41 |
|
| 42 |
The prompt indicates that @ecl{} is now ready to receive a form from the |
| 43 |
terminal and to evaluate it. |
| 44 |
|
| 45 |
Usually, the current package (i.e., the value of @code{*package*}) is the |
| 46 |
user package, and the prompt appears as above. If, however, the current |
| 47 |
package is other than the user package, then the prompt will be prefixed |
| 48 |
with the package name. |
| 49 |
|
| 50 |
@example |
| 51 |
> (in-package "CL") |
| 52 |
#<"COMMON-LISP" package> |
| 53 |
COMMON-LISP> (in-package "SYSTEM") |
| 54 |
#<"SI" package> |
| 55 |
SI> |
| 56 |
@end example |
| 57 |
|
| 58 |
To exit from @ecl{}, call the function @coderef{ext:quit}. |
| 59 |
|
| 60 |
@example |
| 61 |
> (quit) |
| 62 |
% |
| 63 |
@end example |
| 64 |
|
| 65 |
Alternatively, you may type @code{^D} on UNIX-like operating systems, |
| 66 |
i.e. press the key @key{D} |
| 67 |
while pressing down the control key (@key{Ctrl}), |
| 68 |
on Windows, you should use @code{^Z} followed by a return. |
| 69 |
|
| 70 |
@example |
| 71 |
> @myctrl{D} |
| 72 |
|
| 73 |
% |
| 74 |
@end example |
| 75 |
|
| 76 |
The top-level loop of @ecl{} is almost the same as that defined in |
| 77 |
Section 20.2 of @bibcite{Steele:84}. Since the input from the terminal |
| 78 |
is in line mode, each top-level form should be followed by a newline. |
| 79 |
If more than one value is returned by the evaluation of the top-level |
| 80 |
form, the values will be printed successively. If no value is returned, |
| 81 |
then nothing will be printed. |
| 82 |
@example |
| 83 |
> (values 1 2) |
| 84 |
1 |
| 85 |
2 |
| 86 |
> (values) |
| 87 |
|
| 88 |
> |
| 89 |
@end example |
| 90 |
|
| 91 |
When an error is signaled, control will enter the break loop. |
| 92 |
@example |
| 93 |
> (defun foo (x) (bar x)) |
| 94 |
foo |
| 95 |
|
| 96 |
> (defun bar (y) (bee y y)) |
| 97 |
|
| 98 |
bar |
| 99 |
> (foo 'lish) |
| 100 |
Condition of type: UNDEFINED-FUNCTION |
| 101 |
The function BEE is undefined. |
| 102 |
|
| 103 |
Available restarts: |
| 104 |
|
| 105 |
1. (RESTART-TOPLEVEL) Go back to Top-Level REPL. |
| 106 |
|
| 107 |
Broken at FOO. In: #<process TOP-LEVEL>. |
| 108 |
>> |
| 109 |
@end example |
| 110 |
|
| 111 |
@c @vskip 1em |
| 112 |
|
| 113 |
`@code{>>}' in the last line is the prompt of the break loop. Like in |
| 114 |
the top-level loop, the prompt will be prefixed by the current package |
| 115 |
name, if the current package is other than the @code{cl-user} package. |
| 116 |
|
| 117 |
To go back to the top-level loop, type @code{:q} |
| 118 |
|
| 119 |
@example |
| 120 |
>>:q |
| 121 |
|
| 122 |
Top level in: #<process TOP-LEVEL>. |
| 123 |
> |
| 124 |
@end example |
| 125 |
|
| 126 |
If more restarts are present, user may invoke them with by typing |
| 127 |
@code{:rN}, where @key{N} is the restart number. For instance to pick |
| 128 |
the restart number two, type @code{:r2}. |
| 129 |
|
| 130 |
See [@ref{The break loop}] for the details of the break loop. |
| 131 |
|
| 132 |
The terminal interrupt (usually caused by typing @myctrl{C} |
| 133 |
(Control-@code{C})) is a kind of error. It breaks the running program |
| 134 |
and calls the break level loop. |
| 135 |
|
| 136 |
Example: |
| 137 |
@example |
| 138 |
> (defun foo () (do () (nil))) |
| 139 |
foo |
| 140 |
|
| 141 |
> (foo) |
| 142 |
@myctrl{C} |
| 143 |
|
| 144 |
Condition of type: INTERACTIVE-INTERRUPT |
| 145 |
Console interrupt. |
| 146 |
|
| 147 |
Available restarts: |
| 148 |
|
| 149 |
1. (CONTINUE) CONTINUE |
| 150 |
2. (RESTART-TOPLEVEL) Go back to Top-Level REPL. |
| 151 |
|
| 152 |
Broken at FOO. In: #<process TOP-LEVEL>. |
| 153 |
>> |
| 154 |
@end example |