Can messages be sent to processes interactively?
Torbjorn Tornkvist
tobbe@REDACTED
Fri May 21 02:06:00 CEST 1999
> Yes, I did not realize that server functions always need to be exported. I
> see now that spawm() always returns a pid even when the arguments are
> nonsensical: spawn(mud, mud, []). But everything works fine now and I'm
> happily writing concurrent code.
A little helpful comment here:
Think of spawn/3 as:
1. Create a new (empty) erlang process.
2. Perform an apply/3 in the new process.
To be able to do the apply/3 you have to export the M:F/A.
Another little comment: It is very instructive to make
use of the debugger, especially when you write concurrent code.
To use it do the following from your erlang shell prompt;
1> ii(YOUR-MUDULE-NAME).
2> iaa(init).
3> YOUR-MODULE-NAME:foo(....).
A window will now pop-up the first time you execute
the debugged (interpreted) code. From here: singe-step,
inspect variables, etc...
Another useful command is: im().
It will bring up a monitor window displaying all
processes currently being debugged. Attach yourself
to a process by double-click on one of the lines (in the
displayed matrix) representing the process.
Finally: ib(YOUR-MODULE-NAME, LINE-NO).
Sets a break point in a module. By using: iaa(break)
the window will now pop-up when you hit the break point.
All of this can of course be done from the menues of
the monitor window, but the command interface I have
showed here is much faster and easier to use (IMHO... ;-).
/Tobbe
More information about the erlang-questions
mailing list