Le 05/12/2013 18:49, Sam Tobin-Hochstadt a écrit :
[please please please try quoting a little less]
(yes sorry about that. Thunderbird hides quotes, so I tend to forget. I'll be careful)

Contracts mediate the interaction between different components. So to
"add contracts to a program", a programmer specifies that a particular
interaction in the program occurs through a contract.

This is best modeled using a form like I mentioned in an earlier message:

     let newValue = applyContract(contract, value);

Note that `value` is still accessible, of course.
As is hopefully clear above, this isn't how contracts work. Applying a
contract to an object doesn't change the object.
"newValue" suggests otherwise (not that it changes the object, but create a new one, that is value !== newValue), but I feel I'm biased because I think too much in JS. If one can obtain two references to the same object, but with a different contract then the interaction isn't that mediated. On the party with the 2 references is enforced the disjonction of the contract while the intent seems like the conjunction would be more appropriate. In any case, in which conditions can one end up with the same object with two different contracts? Especially if the two contracts are different, it looks like one contract could be violated (if the second contract more relaxed) which sounds going against the developer intent.

Relative to one party with 2 references to the "same" object with 2 different contracts, the interaction with each obejct is different. Are the two references really to the same object, then?

I guess I need to read more about contracts.

Thanks for your answer,

David
_______________________________________________
dev-tech-js-engine-internals mailing list
dev-tech-js-engine-internals@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to