Author Message

Let me thank you for your time and energy.

You wrote

I cannot understand why do get the error in the WRITE mode of
the UNIFY_VARIABLE instruction, because it creates only new
free variable on the heap and copies it to the Register X4 and
increment top of the Haep (see page 13).
Because, the S variable, which should not have been mentioned
is now being increase by 1.  That was the bug in the book.  By
moving the increment of S from always being done regardless of the
mode, to just being done in read mode, solved the problem.
This observation was made by Cees Visser.  

So, here is how the first 6 definitions should have read.  I used
Scheme macros to model the behavior in Hassan's book.  

(extend-syntax (put_structure)
  [(_ f/n Xi)
     (set! Xi (cons 'STR (add1 H)))
     (H-push Xi)
     (H-push 'f/n))])

(extend-syntax (set_variable)
  [(_ Xi)
     (set! Xi (cons 'REF H))
     (H-push Xi))])

(extend-syntax (set_value)
  [(_ Xi) (H-push Xi)])
;---------------------------------------------- WAM
(extend-syntax (get_structure)
  [(_ f/n Xi)
   (let ((addr (deref Xi)))
     (record-case (heap-ref addr)
       [REF __
         (H-push (cons 'STR (add1 H)))
         (H-push 'f/n)
         (bind addr (- H 2))
       [STR a (if (functoreq? (H-ref a) 'f/n)
                  (set! S (add1 a))
                (set! fail #t))]
       [else  (set! fail #t)]))])

(extend-syntax (unify_variable)
  [(_ Xi)
   (case mode
     [(read) (set! Xi (H-ref S)) (set! S (add1 S))]
     [(write) (set_variable Xi)])])

(extend-syntax (unify_value)
  [(_ Xi)
   (case mode
     [(read) (unify Xi S) (set! S (add1 S))]
     [(write) (set_value Xi)])])
;---------------------------------------------- WAM

But, the book had:

(extend-syntax (unify_variable)
  [(_ Xi)
     (case mode
       [(read) (set! Xi (H-ref S))]
       [(write) (set_variable Xi)])
     (set! S (add1 S)))])  ;;; S is not initialized in write mode

(extend-syntax (unify_value)
  [(_ Xi)
     (case mode
       [(read) (unify Xi S)]
       [(write) (set_value Xi)])
     (set! S (add1 S)))])  ;;; S is not initialized in write mode

The difference is the placement of the (set! S (add1 S)).

I am grateful to those who have been kind enough to respond.

... Dan Friedman

Mon, 06 Jul 1998 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. None not None in Excel COM?

2. PythonCOM: com_error: (-2147418113, 'Catastrophic failure', None, None)

3. Proposal: min(None, x) and max(None, x) return x

4. Shouldn't __init__ return self instead of None? (Was: Re: [Tutor] Why error if method __init__ does not return none)

5. (none)

6. (none)

7. (none)

8. (none)

9. <none>

10. None (mail relay)

11. None

12. (none)


Powered by phpBB® Forum Software