Using -spec for callbacks when defining behaviours

Mikael Karlsson karlsson.rm@REDACTED
Sat Mar 20 12:50:55 CET 2010


On Mar 20, 11:26 am, Steve Davis <steven.charles.da...@REDACTED>
wrote:
> Hi Mikael,
>
> A serious omission from "interfaces" that simply enforce type is that
> they totally ignore the concept of state, and are therefore
> necessarily incomplete.
> Contracts (as illustrated by UBF) are definitely more satisfactory...
> If I am understanding the problem correctly (and it's more than
> possible I am not), you'd generally apply contracts to protocols (i.e.
> to the messages exchanged), not to the specific arguments presented to
> the API functions used for any protocol implementation.
>
> regs,
> /s
>

Well, I have a vague idea that contracts may be protocols but also
constraints on arguments (or state data) and that you need to check
them at runtime (see example on contract check in my reply to Kostis
earlier in this thread).
Not all interfaces/protocols carry state, simple client-server non-
transactional requests (like HTTP), for instance and compile time type
checking can cover a lot of an interface specificaton, but in order to
have "everything" in place you probably need to complement with
contract (run-time) checks.

Regards
Mikael


More information about the erlang-questions mailing list