Adding return statement in Anglican for BOPP release
Tuan Anh Le
Branch: tuananhle/anglican:bopp
Branch: probprog/anglican:development
Declined
Declined pull request
overriden by https://bitbucket.org/probprog/anglican/pull-requests/77/add-try-throw/diff
Closed by: Tuan Anh Le·2017-01-26
Adding a return statement in Anglican which allows ending a program when this statement is executed, returning the arguments of this statement, e.g.
(defquery q [x] (let [a (sample (normal 0 1)) b (if (sample (flip 0.5) (sample (normal 0 1)) (return a))] (observe (normal b 1) x) b))
will return either a value of
a
or a constrained value ofb
.The rationale behind this is to be able to do this thing in BOPP (paper): We want to perform a program transformation which allows early termination depending on whether a specified set of variables has been sampled already or not. Details in section 4 of the paper and section 1.5 of supplementary.
What we do is introduce
cps-of-return
which returns a return record, i.e. a non-function CPS, which stops execution. See details in the diff (ignore whitespace).