Communicating between in and out contracts

Denis Koroskin 2korden at gmail.com
Fri Oct 16 13:54:51 PDT 2009


On Sat, 17 Oct 2009 00:28:55 +0400, Denis Koroskin <2korden at gmail.com>  
wrote:

> On Sat, 17 Oct 2009 00:22:54 +0400, Andrei Alexandrescu  
> <SeeWebsiteForEmail at erdani.org> 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.
>>
>> 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.
>>
>>
>> Andrei
>
> When not just let users one variable of type Variant per contract to  
> store whatever they want?

I mean, not a Variant, but a Dynamic* object so that the following would  
be possible:

void push(T)(T val)
in(storage)
{
     storage.oldSize = this.size; // store
     //storage.anyDynamicProperty = anyDynamicValue; in general case
}
out(storage)
{
     assert(storage.oldSize + 1 == this.size); // access
}
body
{
     // impl
}

*do you recall the Dynamic class discussion (a class that allows any  
arbitrary methods and properties access, similar to JavaScript objects or  
dynamic objects in C#)



More information about the Digitalmars-d mailing list