[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gcl-devel] mutual recursion

From: Camm Maguire
Subject: [Gcl-devel] mutual recursion
Date: 07 Jun 2006 22:16:47 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings!  Pehaps the mutual recursion answer is to do like scheme
and inline as you had described earlier.  Deciding when to do so might
be hard, but actually doing it is surprisingly easy it appears:

(defun inline (s1 s2)
  (let ((f1 (si::function-src s1))
        (f2 (si::function-src s2)))
    `(lambda ,(append (cadr f1) '(state))
       (tagbody top
              (macrolet ((,s1 ,(cadr f1) `(progn (psetq 'state t ,,@(mapcan 
(lambda (x) `(',x ,x)) (cadr f1)) (go top))))
                         (,s2 ,(cadr f2) `(progn (psetq 'state t ,,@(mapcan 
(lambda (x) `(',x ,x)) (cadr f2)) (go top)))))
                        (if state (funcall ,f1 ,@(cadr f1)) (funcall ,f2 
,@(cadr f2))))))))

Try loading your tak0 and tak1, compile each, and then (disassemble
(inline 'tak0 'tak1))

Suggestions/comments most welcome.

Take care, 
Camm Maguire                                            address@hidden
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]