Gen.jl
Gen.jl copied to clipboard
Side-effects of `@dist` functions take place at definition time
Example:
julia> using Gen
julia> @dist function labeled_cat(weights, labels)
println("$weights")
labels[categorical(weights)]
end;
Gen.SimpleArg{Any}(1)
This appears to also apply if there is a macro invocation inside the function body that expands to something that has a dollar sign in it.
I've been having quite a go at debugging this :slightly_smiling_face:
Looks like evaluation still works, so the issue is not a big deal. (Plus, it may already be documented that side effects are not expected, in which case I'm a dope)
@bzinberg Maybe we can close this issue, after better documenting that the bodies of dist DSL functions should not have side effects?