Enhanced type guard syntax]

Vlad Dumitrescu vlad_dumitrescu@REDACTED
Thu Sep 18 12:07:27 CEST 2003


Hi,

> Below follows a suggestion regarding enhanced syntax for
> writing type guards in function clauses and in other match expressions.

I think it is  a great proposal, one of those I wish I thought of first :-)

I think the first way looks better, and is also easier to understand.

> foo(A/integer, B/integer) ->
>       A * B.

This is new:
> {X/float, Y/float} = graph:coordinates(),
The alternative today is much hairier to write, so it's a welcomed addition for
me.

Will a type mismatch be treated just as any other pattern mismatch?
I suppose there won't be any automatic type coercions (between float and
integer), would they?
Maybe this could be extended to somehow be able to pack the size() guard in a
similar way (a la binary syntax)?

> The allowed type specifiers should be all the
> type test BIFs named is_XXX/1 but without the "is_" prefix.

I'd like to suggest allowing a "string" type declaration too, making it a
equivalent to "list". Maybe sometime there will be a string type...

regards,
Vlad



More information about the erlang-questions mailing list