page 2  (12 pages)
to previous section1
3to next section

74 Chapter V

pressions containing pointer variables are evaluated as usual since pointer variables must be bound before the evaluation.
? The implementation makes use of the similarity between constraints and instance methods. As discussed in the previous chapter where the word ?function? is used instead of ?instance method?, the major difference between constraints and instance methods is the way they are executed. A method call is executed at once while a constraint is asserted. The assertion stores the constraint in a constraint store without executing the constraint. The constraint is instead executed at solving time. As shown by the sequent rules in the previous chapter, the transformation of a userdefined constraint can be done exactly in the same steps as a user-defined method, which allows a user-defined constraint to be both defined and executed as an instance method. Since both primitive and user-defined constraints are implemented as instance methods, the execution model of the Smalltalk system can be used without significant change. Therefore, a quick (and clean) implementation can be done.
? To delay the execution of constraints in assertions, blocks or closures are used. Constraint assertions are implemented as instance methods of the class BlockClosure which represents compiled programs. The assertion methods simply store the blocks in constraint stores.
? A constraint that has been dynamically asserted is stored in the local constraint store of each of the objects connected to the constraint. A constraint statically asserted, i.e. whose duration is the same as the duration of the surrounding block, is stored in the execution context of the block. When the block has been completely executed, the constraint also disappears with the block.
? Solve- and propagate-methods are implemented in the way outlined in Chapter III. During constraint solving, the stored blocks are executed. Since both primitive and user-defined constraints are implemented as instance methods, the execution of the blocks leads to the execution of the instance methods. The result of the execution of the instance methods is a set of primitive constraints which are input to some primitive constraint solvers and solved by the primitive constraint solvers.