johneastman / boomerang

An interpreted programming language written in Python
https://jeastman.pythonanywhere.com/
MIT License
0 stars 0 forks source link

Language: Investigate Executing Recursive Function as Iterative #58

Open johneastman opened 1 year ago

johneastman commented 1 year ago

To get around Python's recursion limit, it would be cool if recursive calls in Boomerang could be translated iteratively. Either do this in the parser or create a function call stack that is maintained.

The main challenge is maintaining the call state/return values.

johneastman commented 1 year ago

Because everything is an expression (which is to say, everything returns a value), the Shunting Yard Algorithm could work, as it is non-recursive.

Shunting Yard would cut down on recursive calls, but it wouldn't fix recursive function calls created by the user. However, the biggest challenge at the moment is figuring out how to implement Shunting Yard to work with prefix and postfix operators.