spir:

> What is this "old" feature?

It's a basic DbC feature that's currently missing in D because of some 
implementation troubles (and maybe also because Walter is a bit disappointed 
about DbC).

Example: a class member function performs a certain computation and changes 
some attributes. In the postcondition you want to test that such changes are 
correct. To do this well it's useful to know what the original state of those 
attributes was. This is what the "old" feature allows you to do. Similar things 
are possible with free functions too.

So preconditions in a function allow you to assert that general rules about 
inputs are fulfilled, postconditions allow you to assert that general rules 
about its outputs are fulfilled, and the "old" (pre-state) feature allows you 
to assert that general rules about its input-output pairs are fulfilled. So 
it's not a small thing :-)


It was discussed three or more times:

http://www.digitalmars.com/d/archives/digitalmars/D/why_no_old_operator_in_function_postconditions_as_in_Eiffel_54654.html

http://www.digitalmars.com/d/archives/digitalmars/D/Communicating_between_in_and_out_contracts_98252.html


>I definitely need a "mental jump" to think in terms of DbC; nearly never use 
>it, simply don't think at it.<

DbC looks like a very simple thing, but you need some time, thinking, and 
reading about what it is and what its purposes are, to learn to use it :-)

Bye,
bearophile

Reply via email to