Man, this is was one of my favorite articles of all time. I’ve created a functional programming language for my startup thanks for this article. Obviously that there was many things that the article didn’t touch like how to mame tail call optmizations or like how to suuport dictionaries or lists but anyway. This was the quickstart for me for start making things.
I also recommend people reading this book: it is super complete and comprehensive to get started and get your hands dirty
https://monkeylang.org/
Another thing i recommend which is what i ended up doing: instead of interpreting stuff like
I just simply add the values inside of an object and then add like
def visit_BinaryOperation(self, node):
if node.operation == “add”:
return node.right._add_(node.left)
This way i can handle for example what happens if we add a string with a string, or a int with a float INSIDE of the object of this value. So if node.right is an object of type String we handle in the _add_ method in the String class what happens if we add together objects of different types like for example an Int with a String.
But left + right in Python is already syntactic sugar for calling left.__add__(right) and, if that returns NotImplemented, calling right.__radd__(left). So, replacing node.right + node.left with node.right.__add__(node.left) does nothing except sacrifice Python’s built-in fallback handling.
The initial post says that the series will include implementing a debugger, but I don't see that in a scan of the articles. Anyone know if that is still to come, or was dropped, or what?
I also recommend people reading this book: it is super complete and comprehensive to get started and get your hands dirty https://monkeylang.org/
Another thing i recommend which is what i ended up doing: instead of interpreting stuff like
def visit_BinaryOperation(self, node): if node.operation == “add”: return node.right + node.left
I just simply add the values inside of an object and then add like
def visit_BinaryOperation(self, node): if node.operation == “add”: return node.right._add_(node.left)
This way i can handle for example what happens if we add a string with a string, or a int with a float INSIDE of the object of this value. So if node.right is an object of type String we handle in the _add_ method in the String class what happens if we add together objects of different types like for example an Int with a String.
But that’s it. It is an awesome recommendation