;; Not really Joy, but something that can execute the ((dup cons) dup ;; cons) quine using the 'i' (interpretation) combinator. This needs ;; to be an explicit interpreter, because standard eager compilation ;; would destroy the code == list structure. (module joy mzscheme (require "composite.ss" "base.ss" "ns.ss" "ns-base-stx.ss" "rpn-eval.ss" ;; for runtime eval ) (provide joy:) ;; (ns-new '(joy)) (ns-base-stx (joy:) ((joy) (base))) (rpn-modules "joy.ss" "base.ss" "prj.ss") ;; for runtime eval (compositions (base) base: (:joy 'joy: rpn-compile) ;; eager compilation, not joy. (interpret '() cons :joy run) ;; interpret 1 symbol (i (dup symbol? (interpret) () ifte) for-each)) ;; To run a joy program in a base interpreter: quote its program ;; text and pass it to the 'i' combinator, i.e: ;; '( [1 2 3] [10 +] map ) i ;; Note that several things won't work, as primitives that expect ;; programs (which are a different type from lists in base) need to ;; be adapted to work with 'i' instead of 'run'. (compositions (joy) base: (ifte choose i) (dip swap (i) dip) (map 'quote swap '() cons cons ;; (quote LIST) '(i) cons ;; ((quote LIST) i) == ('LIST i) :base map) ) )