Out contracts: how to refer to objects' start state

Idan Arye GenericNPC at gmail.com
Mon May 27 03:19:37 PDT 2013


On Monday, 27 May 2013 at 09:06:58 UTC, deadalnix wrote:
> On Monday, 27 May 2013 at 07:42:44 UTC, Jonathan M Davis wrote:
>> On Monday, May 27, 2013 09:37:38 deadalnix wrote:
>>> On Sunday, 26 May 2013 at 00:43:36 UTC, Andrei Alexandrescu 
>>> wrote:
>>> > That was technically difficult to do back then, and fell by 
>>> > the
>>> > wayside. Today it would break too much code to introduce 
>>> > even
>>> > if feasible.
>>> 
>>> Can you expand more on the breakage risk please ?
>>
>> If nothing else, it would mean that the variables inside of 
>> the in block would
>> not go out of scope when the in block ended, so their 
>> destructors would not be
>> called and the like, whereas now they would be. The same goes 
>> for scope
>> statements in the in block. I don't know how much of an issue 
>> any of that is
>> realistically though. But Andrei may have other reasons why it 
>> would be a
>> problem.
>>
>
> You are right, destructor is an issue. The risk of name 
> collision exists as well but I don't think it is realistically 
> that widespread in actual codebase.

Yet another reason why those variable should be declared as such 
in the `in` clause. Variables declared in the `in` clause using 
the `out` attribute would have their destruction done after the 
`out` clause, and all other variables declared in the `in` clause 
would be destructed after the `in` clause.


More information about the Digitalmars-d mailing list