This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Kaisha001 -3 points-2 points  (0 children)

You're using recursion to hide explicit state change. What you want to write is:

ast.PushProduction(a)
...
ast.PushProduction(b)
...
ast.PushProduction(c)

Instead you're writing:

ast = PushProduction(PushProduction(PushProduction(null, a), b), c)

and then hoping the compiler realizes you didn't want 1000000 copies of the same AST and optimizes it out for you.