Metacircular Interpreter while loop in scheme -


why doesn't while loop work metacircular interpreter. how run in interactions window ?

((while? exp) (eval (while->combination  exp) env))   (define (while-condition expr) (cadr expr))  (define (while-body expr) (caddr expr))   (define (while->combination exp)          (sequence->exp                  (list (list 'define                                    (list 'while-iter)                                           (make-if (while-condition exp)                                                             (sequence->exp (list (while-body exp)                                                                                           (list 'while-iter)))                                                            'true))                            (list 'while-iter)))) 

to answer have used metacircular evaluator described in sicp 4.1.1 since code lacked procedures in order run.

so if have test form (while (call-something) (do-something-1) (do-something-2))) can send quoted while->combination this:

;; nb: notice quote code (while->combination '(while (call-something)                         (do-something-1)                        (do-something-2)))  

if using drracket can put same @ end of definitions window , hit debug >| , step through code easily.

the output i'm getting running is:

(begin    (define (while-iter)      (if (call-something)          (begin (do something-1)                 (while-iter))         true))    (while-iter)) 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -