An old topic (pun intended)

Davidson Corry davidsoncorry at comcast.net
Wed Oct 12 22:29:47 PDT 2011


Did D2 ever implement the Eiffel "old" construct? I do not see it 
mentioned in "The D Programming Language", and the only reference I can 
find in the newsgroup is a short discussion in June of 2007 that seemed 
to go nowhere.

If not, has anyone developed a reasonable workaround? Thanks.

-- Davidson

  ============

Brief description: in Eiffel,
       old expr
can be used in post-conditions, and evaluates to the value of
       expr
as of entry to the function. It's useful to help verify that the 
function has done what it was supposed to, but especially powerful when 
used in classes because it complements invariant:  invariant tests what 
has *not* varied (duh),    old expr   helps test what *has* varied to 
ensure that it has varied *correctly*.

For example, the .Add() method of a Container class might in its 
postcondition assert
        assert( count == old count + 1 )
to ensure that *exactly* one element got added, no more and no less


More information about the Digitalmars-d-learn mailing list