sends don't block, right?
Joe Armstrong
joe@REDACTED
Wed Feb 25 14:48:58 CET 2004
On Wed, 25 Feb 2004, Vlad Dumitrescu wrote:
> From: "Joe Armstrong" <joe@REDACTED>
> > If you use !! at the top level of your code then you can "see" the
> > RPC - my brain goes (RPC this might be slow - take care, and RPC this
> > will synchronize any outstanding asynchronous message) - so I can see
> > what I'm doing.
>
> You make a very nice argument for the !! operator, while explaining some basic
> Erlang philosophy. If only it was easy to specify timeouts, I'd be sold!
>
> /Vlad
>
I wondered about the following:
If we make the following one line addition to erl_parse.yrl:
expr_100 -> expr_150 '!' '!' expr_100:
{call, line('$1'),{atom, line('$1'), rpc},['$1', '$4']}.
Then A !! B just gets expanded into the *local* function rpc(A, B)
and the user is free to add their own definition of rcp/2 to the
module concerned.
So in one module I might say:
rpc(Pid, Q) ->
Pid ! {replyTo, self(), replyAs, Pid, Q},
receive
{Pid, Reply} ->
Reply
end.
In another
rpc(Pid, Q) ->
Pid ! {self(), Q},
receive
{Pid, Reply} ->
Reply;
after 1000 ->
exit(oops)
end.
In another
-include("rpc1.hrl").
In another:
rpc(Pid, Q) ->
gen_server:call(....)
This is more or less how I program - I want all the !!'s to work the
same way in a given scope. ie all of then have timeouts or none, etc.
/Joe
More information about the erlang-questions
mailing list