[erlisp-devel] receiving, pattern-matching
Eric Lavigne
lavigne.eric at gmail.com
Mon Aug 29 16:03:07 UTC 2005
How does receive work? I see that one of the arguments is a pattern
for indicating what sort of message I am interested in, but I don't
understand how to write/interpret such a pattern. Also, will I receive
only the first message that matches this pattern? What happens if no
messages match the pattern? Returns nil immediately? Block until such
a message arrives?
Specifically, I would like to send a list as a message and recognize
the message type based on the first element.
Example (recognize that this starts with 'system):
(list 'system 'link-request 'notify)
I would like to receive the first message from the mailbox in
*current-process* whose first element is 'system, returning
immediately in the case where no such message is found. How could I
set up a pattern-matcher for this? Can I use receive? Or will I need
to use receive-with-timeout and a short time limit?
Better still, is there a way to set up a default handler that would
perform predefined action whenever a message matching its pattern
shows up? If so, I would like to use this. If not, I think it would be
worth adding later. I can imagine writing an entire program made up
entirely of default handlers for various message patterns.
I think that I'm very close to finishing process-linking, but my
confusion over the messaging system is holding me back.
Eric
More information about the Erlisp-devel
mailing list