Communicating between in and out contracts

Jason House jason.james.house at gmail.com
Fri Oct 16 15:07:33 PDT 2009


Andrei Alexandrescu Wrote:

> Jason House wrote:
> > if fun or gun is impure, then they should not be callable by the
> > contracts. Because of that, order is irrelevant.
> 
> 1. Restricting calls to pure functions is sensible, but was deemed too 
> restrictive.

I don't know about others, but my use of contracts have always been pure. If my contracts violate that, then they're serving some other purpose and probably should not be a contract in the first place.

 
> 2. Even so, there's difficulty on what to cache. The amount cached may 
> depend on both the old and new object (in my example it only depends on 
> the old object).
> 
> 3. There's too much hidden work and too much smarts involved. I just 
> don't think that's a feasible solution with what we know and have right now.

You never asked if it was too much work for Walter ;)

Honestly, I think it may be simple enough to allow static (immutable) variable declarations within the in contract to be seen in the out contract. Maybe it isn't done with the static keyword.

in{
  keep oldLength = length;
  ...
}
out{
  assert(oldLength == length + 1;
}



More information about the Digitalmars-d mailing list