Enhanced type guard syntax]

Joe Armstrong <>
Thu Sep 18 15:57:55 CEST 2003


On Thu, 18 Sep 2003, Fredrik Linder wrote:

> > foo(A/integer, B/integer) ->
> >       A * B.
> >
> > {X/float, Y/float} = graph:coordinates(),
> 
> This looks really really nice!
> 
> Again, I'd like to ask for user-defined guards, as it would really enhance
> ... erlang(?).
> 

  No - guards are extensions of patterns. They have to be  simple, 
so that a pattern matching compiler can do a good job on them.

  If we had user defined guards somebody will write:

	foo(X) when bar(X), a == b ->
	   ...

  Where bar(X) a user defined guard.

  Now what happens if somebody writes:

	bar(P) -> P ! a, true.

  But the guard fails (ie a==b) fails, did the message get sent?????

  Cheers

/Joe





More information about the erlang-questions mailing list