[erlang-questions] Ideas for a new Erlang

Sven-Olof Nystr|m svenolof@REDACTED
Sat Jun 28 11:17:36 CEST 2008


Robert Virding writes:
 > On 26/06/2008, Richard A. O'Keefe <ok@REDACTED> wrote:
 >
 > > p6. "The complex selective receive primitive of old Erlang
 > >       has forced the Erlang designers to introduce a more
 > >       restricted type of expressions called _guards_."
 > >
 > > This is fiction, and it's fiction with a major error in it.
 > >
 > > Guards are *NOT* a restricted type of expression.
 > 
 > Richard is absolutely right here. Guards were always seen as part of
 > pattern matching, the bits which you could not easily write in the
 > patterns. They have always been a sequence of *tests* which either
 > succeed of fail, there has never been a concept of error in guards. In
 > this sense they have never been proper expressions, even restricted
 > ones. Boolean operations were added to expand guards and tests the
 > changed to more resemble expressions, for example tuple(T) =>
 > is_tuple(T), but guard tests are not expressions, they are *tests*.

As I already explained in my reply to Richard, I meant expressions in
a general sense.

Expressions in C or C++ are expressions. So are expressions in Java,
Common Lisp and most other programming languages. Even regular
expressions are expressions. Can you give a definition of the concept
"expression" that excludes guard tests of Erlang and includes all
other types of expressions?

 > It might have been the wrong to expand the tests with boolean
 > operations as it means that it is more difficult to see the
 > difference, and hence to understand it.
 > 
 > But they are not expressions, they never have been, they are tests!

What I really wanted to say was that guard tests of Erlang are strange
and unusual. I see nothing in your posting that contradicts that.

 > Robert
 > 
 > P.S. I have seen attempts, not in Erlang, to include the "guard" bit
 > in the patterns and they were *very* hard to read.

Not sure what that means.


Sven-Olof




More information about the erlang-questions mailing list