-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlfe_shell.txt
155 lines (107 loc) · 4.67 KB
/
lfe_shell.txt
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
MODULE
lfe_shell
MODULE SUMMARY
Lisp Flavoured Erlang (LFE) shell
DESCRIPTION
There is now a simple LFE shell in which you can enter sexprs
which are evaluated and the value printed. You can define
functions and macros as well as set variables.
Built-in shell functions
These are defined as normal functions and macros and can be
called from anywhere in the shell. They can even be redefined.
They can also be explicitly called (: lfe_shell ...).
(c File [Options])
Compile and load an LFE file. Assumes default
extension .lfe.
(ec File [Options])
Compile and load an Erlang file.
(i)
Print information about the currently running
processes in the system.
(l Module ...)
Load modules.
(m Module ...)
Print out module information, if no modules are given
then print information about all modules.
(pid x y z)
Create a pid from x, y, z.
(p Expr)
(pp Expr)
Print/prettyprint a value to full depth.
(regs)
Print information about the currently running
processes in the system.
(: c Command Arg ...)
All the commands in the standard Erlang shell can be
reached in this way.
Built-in shell commands
These are special forms which are only recognised at the
top-level in shell input. The cannot be redefined.
(reset-environment)
Resets the environment to its initial state.
(set Pattern Expr)
(set Pattern (when Guard) Expr)
Evaluate Expr and match the result with Pattern
binding variables in it. These variables can then be
used in the shell and also rebound in another set.
(slurp File)
Slurp in a source LFE file and makes all functions and
macros defined in the file available in the
shell. Only one file can be slurped at a time and
slurping a new file basically does an unslurp first.
(unslurp)
Revert back to the state before the last slurp
removing all function and macro definitions both in
the slurped file and defined in the shell since then.
(run File)
Execute all the shell commands in File. All defined
variables, functions and macros will be saved in the
environment if there are no errors.
Shell functions and macros
Functions and macros can be defined in the shell. These will
only be local to the shell and cannot be called from
modules. The forms are the standard forms for defining
functions and macros.
(defun Fun ...)
Define a function in the shell.
(defmacro Macro ...)
Define a macro in the shell.
Built-in shell variables
+/++/+++
The three previous expressions input.
*/**/***
The values of the previous 3 expressions.
-
The current expression input.
Shell Environment
The shell maintains an environment of local function and macro
definitions, and variable bindings. The environment can be
accessed using the built-in shell variable $ENV. This can be
useful when calling functions like macroexpand and
macro-function which unless an explicit environment is given
will only search the default environment.
Starting the LFE shell
After installing the best way is probably to start Erlang
directly running the LFE shell with:
lfe [flags]
From a normal Erlang shell the best way to start the shell is
by calling:
17> lfe_shell:server().
Giving the user switch commands:
--> s lfe_shell
--> c
will create a job running the LFE shell and connect to
it. This also works when starting a remote shell.
Running LFE shell scripts
The LFE shell can also be directly called to run LFE shell
scripts with:
lfe [flags] file [args]
This will start the shell, run a script with LFE shell
commands and then terminate the shell. The following built-in
variables are also bound:
script-name
The name of the script file as a string.
script-args
A list of the arguments to the script as strings. If
no arguments have been given then this will be an
empty list.