Hacker News new | past | comments | ask | show | jobs | submit login

Yes OLD stores the value of the variable before the execution of the DO.

This is because all of the virtual methods that have been overriden are visited in order to gather their assertions, but not execute their DO(). So while the assertions are being collected it also collects OLD() values which then can be tested at the called virtual method in its ENSURE() clause.

OLD is a complicated mechanism to implement in C++ because it requires saving current variables at the same time deferring the code to be executed.

Using the OLD() and ENSURE() (along with the other) clauses together, is described as subcontracting where subclasses "require less" and "ensure more", given in the https://en.wikipedia.org/wiki/Object-Oriented_Software_Const... (first edition).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: