Eval function inside a trait
Hello, I was wondering if the eval/evalenv definitions in the interpreter related videos couldn’t be part of a trait which is extended by all expressions?
That way each expression would be responsible for implementing its own way to be evaluated, which seems to represent a better encapsulation.
Furthermore, if we add a new case class to expression, we only need to add code to this precise class and we don’t need to go back modifying a global Eval def.
We could still have a general eval function which takes an expression as argument and only calls its eval