-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Via @stephentyrone on Twitter:
Yes! Great to have this for teaching how to think about architecture too. What if we added an instruction that did X? Well, now you can just add it and teach the compiler to emit it and find out!
Which got me thinking about implementing the interpreter's core functionality in such a way that additional instructions can be implemented later on. I think this would also involve providing the Instruction supertype from ast.rkt.
I'm not totally sure how best to go about this. Xsmith had extensible grammars and such implemented through a (highly complicated) macro system (that I did not fully understand)... perhaps something like that would work? Or else the step function could be made such that its wildcard case calls a function stored in a parameter (from make-parameter) which can be overridden or something.
Or maybe... there could be a macro provided to define-new-instruction that requires a clause to be defined, which can be inserted into the match? Perhaps this is just a wrapper around the parameter idea? Unsure. Need to think on it more.