[erlang-questions] Changing the shell and module syntax and semantics
Thu Mar 8 12:50:06 CET 2007
--- Joe Armstrong <erlang@REDACTED> wrote:
> all we need to do is add an invisible
> "-module(shell)" to
> the session, remember all the stuff that's typed in
> as new functions come either compile the complete
> module (so far)
> or interpret the code.
I think Prolog can show the way in that case. In
Prolog, you can "consult" files to read in predicate
definitions, but also consult from a special name,
'user', where you type in definitions directly. Here
is an example: I consult from user, type in f/1, exit
the consult, then run f(X) (search for solutions
binding X). For those not familiar with Prolog, note
the uncanny similarity in syntax :-)
localhost % gprolog
GNU Prolog 1.3.0
By Daniel Diaz
Copyright (C) 1999-2007 Daniel Diaz
| ?- [user].
compiling user for byte code...
user compiled, 3 lines read - 262 bytes written, 6665
| ?- f(X).
X = a ? ;
X = b
(Reading from 'user' was terminated by EOF, control-D,
which doesn't show in the above.)
Happily, Richard O'Keefe probably knows all there is
to know about this topic already.
I would suggest a shell command for doing the above,
but rather than having an implicit module 'shell', I
would generalize it a bit. The command might be named
e.g., "def(my_module)" and could work like this:
- read forms until EOF
- stick "-module(my_module). -compile(export_all)." in
front of the forms
- compile and load them as my_module
It might be nice to be able to extend or revise an
existing module too, at least one created with def/1,
particularly if there is a compilation error ...
Anyway, such a capability would subsume your proposal.
8:00? 8:25? 8:40? Find a flick in no time
with the Yahoo! Search movie showtime shortcut.
More information about the erlang-questions