That’s really interesting. It seems like this with your Loop
construct could be great for probabilistic programming. It would probably take some extension though. In PPL, for any loop that includes sampling, we’d need (or prefer anyway, I think) to be able to pick up at an arbitrary iteration. This could be something like a sequence of loop states stored as a StructArray.
That’s fine for some applications. But for me, for example rand
needs to build code to sample from a model. This is usually in an inner loop, so it’s important that it only be built once for each type-distinct set of arguments. I think there are lots of other subtleties beyond this. Basically things got a lot better when I started avoiding eval
when possible.