out contract misunderstanding (was: I cannot understand problem with argument of the function)

Ivan Kazmenko gassa at mail.ru
Thu Sep 19 11:01:08 PDT 2013


On Thursday, 19 September 2013 at 07:45:44 UTC, monarch_dodra 
wrote:
> On Thursday, 19 September 2013 at 06:39:09 UTC, Ivan Kazmenko 
> wrote:
>> On Thursday, 19 September 2013 at 01:41:15 UTC, mrd wrote:
>>> Why argument "value" in contract isn't equal 2 ?
>> Why should it be?  <snip>
> I actually disagree though: How the function is implemented 
> should have no bearing on how the output contract should be 
> implemented. Both should get their own copy of the args. The 
> implementation of a function should not have to create a local 
> duplicate just because it happens to know that it has an out 
> contract.
>
> This is particularly relent since (in theory), an in/out 
> contract should appear in a function's interface, and 
> compiled/called by client code (though that's not the case 
> today).

That doesn't seem to be possible in every case.  For example, 
what if an argument is a class with copy constructor disabled?

I'm not claiming that the current behavior is the best one.  I 
just don't get a coherent picture of how it could be defined 
otherwise.  And the current definition seems to follow the 
principle of least surprise for me.

Ivan Kazmenko.


More information about the Digitalmars-d-learn mailing list