Enhanced type guard syntax]

Vlad Dumitrescu vlad_dumitrescu@REDACTED
Fri Sep 19 08:40:07 CEST 2003


> foo(A/integer, B/integer) ->
>       A * B.
>
> {X/float, Y/float} = graph:coordinates(),

***

I think records should also be encompassed by this notation. But how to extend
it to allow specification of a record name?

foo(A/record#myRecord) ->
foo(A/#myRecord) ->

First one is more consistent with the parallel to the is_XXX bifs, but longer.

***

Valentin wrote:
>Inability to comprehend the value that this syntax would add makes me think
>that the whole thing is about ideology and programming puritanism.

As I see it, it's only syntactic sugar. The value is most visible when the only
guards are type declarations, and when there are many parameters with longish
names.

myFun(FirstArgument, SecondArgument, ThirdArgument)
    when is_integer(FirstArgument),
             is_float(SecondArgument),
            is_list(ThirdArgument) ->

myFun(FirstArgument/integer, SecondArgument/float, ThirdArgument/list) ->

regards,
/Vlad




More information about the erlang-questions mailing list