Closed Antigen-1 closed 1 year ago
Dear Antigen-1,
I like your creative thinking!
What you're proposing may not be a simple as it appears at first. There are a couple things to consider:
(read)
? In particular, you would need to make sure that the ordering of the side effects is unchanged by the optimization.patch_instructions
is still need.)Happy exploring, Jeremy
Dear Jeremy,
Thanks for your reply!
First and foremost, it is unnecessary for typical partial evaluators to remove (define <var> <var>)
from the sequence when the value of the latter variable is unknown. Though I do implement this feature and the optimizer can handle correctly the order of complex expressions, it still appears to be unnatural, and that is exactly why I closed this issue yesterday.
As for later chapters, the optimizer, in fact, might still work if conditionals and loops are converted into Cvar statements. The structure of the Cvar language reminds me of modules that contain code blocks, say, procedures, submodules, macros and the like. Maybe I can add clauses to the match
form to extend the optimizer.
It's appreciated again for your kind suggestions. I'll continue to improve my compiler, taking these factors into consideration!
Yours frankly! Antigen-1
What you're proposing may not be a simple as it appears at first.
I think you are right, sir. The optimizer cannot remove all (define <var> <var>)
. Worse still, it fails to undertake as much computation as possible at the compile time.
Hello!
I'm just a reader of this book and a complete novice at designing compilers.
According to page 32,
That means if we initialize an variable using another variable, then the compiler will produce
movq <ref> <ref>
, which is not allowed in x86.In order to resolve this, actually we can implement a partial evaluator for the Cvar intermediate language rather than the Lvar language. That certainly eliminates this condition from the sequence, rendering the
patch_instructions
pass unnecessary. And I found it much easier than overcoming the challenge described in section 2.11.Here is my optimizer(Yet I adopt another representation of the Cvar language to make it easier to write the definitional interpreter and enforce contracts).
Nevertheless, I feel unqualified to remark on curriculum design and this is merely my suggestion.
Yours sincerely Antigen-1