[erlang-questions] clarify: Sending big messages
Zoltan Peter Toth
zoltan.peter.toth@REDACTED
Wed Oct 22 16:44:53 CEST 2008
> > deliver(Port, Data) ->
> > Port ! {data, Data}.
> >
> > This function returns Data.
>
> Nope. This function returns {data, Data}.
>
Oops, sorry. Such things will not bypass the attention of the creator of
dialyzer, though :)))
>
> I personally think that !/2 returning a value instead of being void as
> it should, is a design flow in the definition of the language. (*)
>
>
> Trouble is there is no void data type and every expression must return
> a value. So we decided that as it must return something it might as
> well return something useful, so why not the message? Personally I
> think this is better than returning 'ok' or 'void'.
It's probably a matter of taste... however, imho:
- the message to be sent is obviously available in the function invoking
!/2. I see no gain from
returning it. If one needs it, it can be bound to a variable before
sending.
- it would be safer to return ok: otherwise it's easy to cause trouble
with an unconsidered rpc.
It's easy to run into that if one calls a function via rpc that calls
others locally, and the call stack
may somehow end with a !/2 in certain cases.
/Zoltan
More information about the erlang-questions
mailing list