[erlang-questions] clarify: Sending big messages

Hynek Vychodil vychodil.hynek@REDACTED
Wed Oct 22 16:47:38 CEST 2008


On Wed, Oct 22, 2008 at 4:31 PM, Kostis Sagonas <kostis@REDACTED> wrote:

> 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),
>       loop(NewState).


Yes, those function doesn't return at all, it is not same as return nothing.
Well to clarify it, each function return some value or crash (raise
exception). There is not any function returning nothing so claim "Everything
returns something" is true with little add-on, "if returns".

>
>
> > 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.


Why? Why there should be this extra unit?

>
>
> > 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.
>
> Kostis
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



-- 
--Hynek (Pichi) Vychodil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081022/506565e4/attachment.htm>


More information about the erlang-questions mailing list