dimitriv / Ziria

A domain-specific-language and compiler for low-level bitstream processing.
92 stars 18 forks source link

Don't "partially evaluate" prints with multiple arguments #94

Closed edsko closed 9 years ago

edsko commented 9 years ago

The interpreter will execute prints with statically known arguments at compile time rather than at runtime, but if you write something like

print "The value of a is", a

in the source, this gets translated to two print statements in the AST, and consequently the interpreter will execute the first but not the second. We should change the AST so that print takes multiple arguments, and then change the interpreter so that it only executes the whole thing of all arguments are statically known.

dimitriv commented 9 years ago

I will close this as the commit above addresses the issue. I think we can clean up he print state in the Interpreter but I will refrain from doing this in case we need to revert some of this in the future.

edsko commented 9 years ago

With the change of having multiple arguments to print I think you could revert the behaviour of the interpreter. The point was that you could have print statements in code that was meant to be executed completely statically (computation of tables etc) so that you could debug it (and have the print statement shown at compile time instead). The behaviour was confusing because of the single-arugment problem, but that's gone now? Anyway, just my 2c :)

edsko commented 9 years ago

(Note that with your change, if you do insert print statements in otherwise statically evaluable code, the code will not be executed at compile time.)