Commits

Anonymous committed 2cf632e

add scheme* as escape hatch, the usefulness of which has yet to be determined

Comments (0)

Files changed (2)

   (make-hash-table))
 
 (define clojure-primitives
-  '(def fn* let* loop* recur do quote in-ns ns var
+  '(def fn* let* loop* recur do quote in-ns ns var scheme*
         ;; the following primitives should be implemented in Clojure
         ;; itself later on
         use defprotocol binding))
         (else
          (map clojure-compile (cons sym args)))))
 
+(define compile-scheme*
+  (match-lambda
+   ((form)
+    (if (string? form)
+        (call-with-input-string form read)
+        (error 'scheme*
+               "bad argument type - expected string"
+               form)))
+   ((forms ...)
+    (cons '~begin (map compile-scheme* forms)))))
+
 ;; compiles a Clojure form as returned by clojure-read to Scheme
 ;;
 ;; TODO: this won't work in normal Scheme modules (i.e. those not
                 (('recur args ...)
                  (clojure-compile `(~recur . ,args)))
                 (('binding rest ...)
-                 (compile-binding rest))))
+                 (compile-binding rest))
+                (('scheme* forms ...)
+                 (compile-scheme* forms))))
              (else
               (compile-fn-application sym rest)))))
     ((? pair?)
          "(def ^:dynamic foo 123)"
          "(let [foo 99 bar foo] (list foo bar))"))
 
+(test-group "scheme*"
+  (test* '^foo "(scheme* \"'^foo\")")
+  (test* '(foo (~bar)) "(scheme* \"'(foo [~bar])\")")
+  (test-error*  "(scheme* foo)"))
+
 (test-end "clojure")
 
 (test-exit)