Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

TAILPROG

Name: Anonymous 2010-01-31 11:01


(defmacro tailprog (let-bindings pseudo-funcs &rest forms)
  (let (argtags-forms macrolet-elems)
    (dolist (pfunc pseudo-funcs)
      (destructuring-bind (name vars &rest forms) pfunc
        (push `(label ,name ,@vars) argtags-forms)
        (push `(return (progn ,@forms)) argtags-forms)
        (push `(,name (&rest args) `(goto ,',name ,@args)) macrolet-elems)))
    `(macrolet (,.(nreverse macrolet-elems))
       (let ,let-bindings
         (argtags nil
           (return (progn ,@forms))
           ,.(nreverse argtags-forms))))))

ALL YOUR TAIL RECURSION R BELONG TO US

Name: Anonymous 2010-02-01 16:45

>>15
;;; However, such optimizations can only be performed
;;; if one can prove that certain previous bindings
;;; will not be needed, which is not always the case.


If the previous binding is still needed, the new dynamic-let is not in tail position of the previous dynamic-let body. Problem solved, implementation left as an exercise for the reader.

http://docs.plt-scheme.org/reference/parameters.html#(form._((lib._scheme/private/more-scheme..ss)._parameterize))

Also, http://dis.4chan.org/read/prog/1263180589/77

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List