Interperter design: Operators
Making a language is a challange task, today I'll cover my thought process on how I implemented operators.
Operators, the thing we probably take most for granted in every language. We just use them, they're the base of every single function. So how do you implement that? And what do even is an operator?
I would define an operator as something that operates on an expression manipulating it into something else. So what's the difference between an operator and a function? A function can do anything you want, while an operator must operate on the expression/s provided and return a resulting value. For example the equality operator returns a booleanic value depending on the equality of two expressions.
So how does that affect our implementation? Should we add to the base Expression interface all of thesse operators? Do we let the operator expressions handle all of this? I mixed the two.
Comments
Post a Comment