Communicating between in and out contracts

Rainer Deyke rainerd at eldwood.com
Fri Oct 16 19:36:02 PDT 2009


Andrei Alexandrescu wrote:
> Rats, I meant assert(old.gun(i * i)). That's what compounds the
> difficulty of the example.

That wouldn't be allowed.  More specifically 'old(gun(i * i))' wouldn't
be allowed.  'old(this).gun(i * i)' would be allowed, but probably
wouldn't do what you want it to do.  'old(this.clone()).gun(i * i)'
would be allowed and would work, assuming that the 'clone' method is
defined and has the right semantics.

The general rule is that for any 'old(expr)', 'expr' only has access to
variables that are accessible in the 'in' block.  Preferably const access.

> I honestly believe the whole "old" thing can't be made to work. Shall we
> move on to other possibilities instead of expending every effort on
> making this bear dance?

It definitely /can/ be made to work, for some value of "work".  It
sacrifices the natural order of evaluation to gain a concise and
intuitive syntax.  I don't think it should be dismissed out of hand.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list