next up previous
Next: Latency Hiding Up: Object Replication Previous: Mechanism

Syntax

Here, we show an example syntax that creates replicas. The syntax uses the reflective annotation so that base-level programmers can exploit the replication mechanism without modifying the structure of the original programs. The annotation to create replicas is written as follows:
exp{replicate ( 17#17) :when pred}
When this annotated expression is to be evaluated, pred in the annotation is evaluated first. If the result is true, replicas of objects that are bound to the variables 17#17 are created; and the exp is evaluated in an environment such that the variables 17#17 are bound to the replicas. We can add annotations to the function product shown in Figure 2, so as to employ replicas. The program with annotations is shown in Figure 8. Note that the only difference between this program and the original one is the addition of the annotation.
  
Figure 8: Dot-production function using a replica
18#18

As stated in the previous section, the interpretation of annotations can be modified by overriding method eval-annotation. Here, we define a class replica-eval and a method eval-annotation, as is shown in Figure 9.
  
Figure 9: Interpretation of replica-creating annotations

1: (defmethod replica-eval eval-annotation (body args env)
2: (if (eval self (replica-predicate args) env)
3: (let* ((target (replica-target args))
4: (obj (lookup target env))
5: (rep (denotation (copy-object (meta obj) (this-pe))))
6: (ex-env (extend-env env (list target) (list rep))))
7: (let ((answer (eval self body ex-env)))
8: (copy-back (meta rep))
9: answer))
10: (eval self body env)))

1: (defmethod replica-eval eval-annotation (body args env) 2: (if (eval self (replica-predicate args) env) 3: (let* ((target (replica-target args)) 4: (obj (lookup target env)) 5: (rep (denotation (copy-object (meta obj) (this-pe)))) 6: (ex-env (extend-env env (list target) (list rep)))) 7: (let ((answer (eval self body ex-env))) 8: (copy-back (meta rep)) 9: answer)) 10: (eval self body env)))


(l.2) It evaluates pred in an annotation. If it is true, (l.5) a replica of a specified object is created. The functions denotation and meta return corresponding base-level object and meta-object, respectively; and the function this-pe returns a current processor ID. (l.7) The body of the expression is then evaluated in an extended environment. (l.8) Method copy-back is a user-defined method of the replicated metaobject, which writes values of instance variables in the original metaobject's for consistency management. (l.10) If the pred is false, it evaluates the body of the expression as usual.


next up previous
Next: Latency Hiding Up: Object Replication Previous: Mechanism
Matt Hurlbut
1998-07-14