[please please please try quoting a little less] On Thu, Dec 5, 2013 at 11:50 AM, David Bruant <bruan...@gmail.com> wrote:
> From reading this thread I feel I'm severely lacking the proper background, > but I'd like to try a question anyway. > > 1.3 Use Case: Contracts: >> >> During maintenance, the programmer may add contracts to a program as >> understanding improves. > > What does "add contracts" mean? "Add" contracts to a given object/function > which already have one? Add contracts to things that didn't have any > beforehand? 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. It's useful to use the intuition of legal contracts (hence the name). If you and I sign a contract for you to use my car, that doesn't change the car, but it constraints the interaction between you and the car. >> Clearly, the addition of a new contract must not change a program >> execution that respects the contract already. > > Agreed. > >> In this scenario, the program executes in a mix of original objects and >> proxy objects. > > I don't understand why. The way I see it, an object with a contract is an > object replaced in the runtime by a proxy which handler implements the > contract. When I write "replace", I mean that the object constructed as a > proxy. Otherwise, there are places where the contract can't and won't be > enforced. > By my definition, the original object is only available to the proxy as its > target and no other context. Also, even if piling contracts, only one proxy > is available in the end (previous proxy becomes target of next contract > proxy). > Or is the contract different based on where the object is sent? If the > answer is yes, is it really the same object? Isn't it rather a façade to the > target (and should effectively be a different object, most likely a proxy) As is hopefully clear above, this isn't how contracts work. Applying a contract to an object doesn't change the object. Sam _______________________________________________ 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