2 ms·
Why is a written specification better than the code that implements it? One might suppose that a written spec is less mutable, but why should that be? The examp
by hgomersall 2y ago
Why is a written specification better than the code that implements it? One might suppose that a written spec is less mutable, but why should that be? The example provided is not particularly good since the semantics are well defined and can be looked up in the code. A better example would be one where what happens is not well defined, but I'm not aware of any of those places in rust.
Essentially, any change to the code that changes the semantics is a breaking change and will be avoided, just as any change to the spec would be a breaking change and would be avoided.
- gpderetta 2y agoThe reason is that if the code is the specification is not obvious when a certain behaviour is an intended feature or a bug. Specifications can have bugs of course, but when the spec and (potentially multiple) implementations agree gives more confidence on expected behaviour. A conformance suite can be an alternative of course, but it is not necessarily always possible to infer general behaviour from a test case.