Running the program
prog = compile_pgcl("""
const c := 42
nat x
x := c : 1/2 + 2 : 1/2
x := c
""")
print(prog)
gives the following output:
const c := 42;
nat x;
x := c : 1/2 + 2 : 1/2;
x := 42;
The constant in the categorical expression isn't substituted. This happens because the different subexpressions in a CategoricalExpr aren't stored as top-level attributes (sensible), but in a list of subexpressions with probabilities. This however means that the built-in walk over the expression doesn't yield these subexpressions due to the way children are discovered in mut_expr_children.
I already changed this on the brand-new branch to enable walking over the parameters of a function call. However, the problem with CategoricalExprs persists, as their subexpressions are stored in tuples, which are immutable and thus don't allow for substitution.
Running the program
gives the following output:
The constant in the categorical expression isn't substituted. This happens because the different subexpressions in a
CategoricalExpraren't stored as top-level attributes (sensible), but in a list of subexpressions with probabilities. This however means that the built-in walk over the expression doesn't yield these subexpressions due to the way children are discovered inmut_expr_children.I already changed this on the
brand-newbranch to enable walking over the parameters of a function call. However, the problem withCategoricalExprs persists, as their subexpressions are stored in tuples, which are immutable and thus don't allow for substitution.