[erlang-questions] is there "return" in Erlang.

Jachym Holecek freza@REDACTED
Mon Feb 28 16:47:11 CET 2011


# Attila Rajmund Nohl 2011-02-28:
> 2011/2/28, Jachym Holecek <freza@REDACTED>:
> [...]
> > Oh, true, forgot about that -- but the one with 'if' can't, or consider
> > 'switch' as another example. Point is in C, some things are statements
> > which do things without having a value themselves and some things are
> > expressions yielding values.
> >
> > In Erlang, life is simpler -- everything is an expression, you can bind it
> > to a variable or just use it in-place anywhere an expression is allowed.
> 
> Except the throw statement...

What do you mean? Throw and friends are not statements but functions and
there's not necessarily anything magic about them, on conceptual level,
as I've tried to allude to earlier.

> > This means you can compose small bits of meaning in any way you want, free
> > from arbitrary limitations like the ones in C.
> 
> Erlang has its own set of "arbitrary limitations", for example you
> can't write any kind of exception in an 'if'...

Yeah, for some reason unknown to me 'if' only likes guard tests, but at least
it's not like there aren't perfectly usable alternatives to this. I suppose
your point was that nothing is perfect, with which I of course agree, and
I hope my point about the value of consistency (or how else to put it) didn't
get lost in the details.

Regards,
	-- Jachym


More information about the erlang-questions mailing list