probcomp / metaprob

An embedded language for probabilistic programming and meta-programming.
GNU General Public License v3.0
168 stars 17 forks source link

Make closures created by the interpreter be callable from clojure #47

Closed jar398 closed 5 years ago

jar398 commented 6 years ago
((block (define [fun _ _]
          (infer :procedure (gen [x] (gen [y] (+ x y))) 
                 :inputs [3] 
                 :output-trace? true))
        fun)
 4)
ClassCastException clojure.lang.Atom cannot be cast to clojure.lang.IFn  metaprob.examples.all/eval9041 (form-init4440039299882098981.clj:113)

Here the inner gen procedure is created by the metacircular interpreter. Currently such procedures are not callable from clojure; formerly this was impossible because there was no way to maneuver the lexical environment into the clojure copy of the code. But now we have the environment and it should be possible to make this work.

zane commented 5 years ago

This appears to work now.