[erlang-questions] -protocol declartion idea, worth an EEP?
Mon Jun 5 16:56:01 CEST 2017
> Or more generally, the "catch-all" idiom
> good1 -> ...
> ; good2 -> ...
> ; _ -> loop(...) % discard bad messages
Yes, definitely. I was assuming that A was unbound.
> 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.
You're right. Wildcards are definitely a special case that
can hide a lot of (dangerous) communication problems.
Though I'm not clear where this macro should be: in the
protocol spec or the receive?
> 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
Oh right. That makes much more sense :)
> 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.
Yep! It seems like a good idea to make these compositional.
More information about the erlang-questions