[erlang-questions] -protocol declartion idea, worth an EEP?

Mon Jun 5 15:16:36 CEST 2017

> The problem I see is simple. If you have an irrefutable pattern,
> it covers *all* of your receive specifications:
> receive
>   A -> ok
> end.

Or more generally, the "catch-all" idiom
      good1 -> ...
    ; good2 -> ...
    ; _ -> loop(...) % discard bad messages
I was thinking of having a macro ?CATCHALL for this,
with different translations for ordinary compilation
(_) and checking (something else).  Or perhaps more
simply, treating a single wild-card in receive as a
special case.

>> If you want to specify that a function doesn't receive
>> anything, use 'receive none()'; any empty OptRcv says nothing
>> about the function's protocol.
> I disagree. This would mean that all "pure" functions require
> annotations. This seems pretty tedious.

The problem is that right now fun() and -spec say *nothing*
about reception.  Backwards compatibility seems to require
not changing that.

The idea was that a checker should *infer* 'receive none()'
for pure functions, and that this should *refine* a given

One thing I was after was that you should normally require
just one -protocol declaration per process, with the
receive part of the functions it calls being inferred.

More information about the erlang-questions mailing list