[erlang-questions] clarify: Sending big messages

Kostis Sagonas kostis@REDACTED
Wed Oct 22 16:31:42 CEST 2008

Johnny Billquist wrote:
> Kostis Sagonas wrote:
>> Zoltan Peter Toth wrote:
>>> Hi,
>>> We have a function like this:
>>> deliver(Port, Data) ->
>>>     Port ! {data, Data}.
>>> This function returns Data.
>> Nope.  This function returns {data, Data}.
>> 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. (*)
> ???
> Erlang is a functional language. Everything returns something.

Well, not quite.
For example the following function does not return anything at all:

   foo() -> exit("hello world").

Here is another one:

   bar() -> throw(42).

One more:

   loop(State) ->
       NewState = do_something_with(State),

> There is no "void".
> Maybe it should always return "ok" instead,

Of course that's what pretty much what I meant.  In today's state of 
Erlang, it should return 'ok' (the atom, not the string).  In an ideal 
world, it should return an opaque value (unit?) which, in some sense, is 
the equivalent of the function being void.

> but I think it's better it 
> returns the expression sent, in case you do want to play around with it 
> somehow.

You are of course entitled to this opinion.


More information about the erlang-questions mailing list