Skip to content

Add tail-call optimisations + General changes#150

Open
AaravMalani wants to merge 8 commits intomainfrom
add-tco
Open

Add tail-call optimisations + General changes#150
AaravMalani wants to merge 8 commits intomainfrom
add-tco

Conversation

@AaravMalani
Copy link
Copy Markdown
Member

@AaravMalani AaravMalani commented Apr 25, 2026

  • Add Python 4 and MCE to the documentation
  • Rename __PROGRAM__ to __program__ to align with Python's naming scheme
  • Add __program__ which stores the code of the program being evaluated
  • Extend apply_in_underlying_python to support non-primitive functions
  • Add stack overflow checks + tail call optimisations

Fixes #144

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the Python interpreter by implementing Tail-Call Optimization (TCO), adding recursion depth tracking with a corresponding RecursionError, and exposing the __program__ variable. It also updates documentation, refines the standard library's error handling, and extends apply_in_underlying_python to handle non-primitive functions. Feedback includes suggestions to avoid redundant property initialization, replace magic numbers with named constants for recursion limits, and use more robust undefined checks for builtin function results.

Comment thread src/engines/cse/control.ts Outdated
Comment thread src/engines/cse/utils.ts Outdated
Comment thread src/engines/cse/interpreter.ts Outdated
@martin-henz
Copy link
Copy Markdown
Member

Great to see this PR. A significant step to a realistic Python implementation for CS1101S.

AaravMalani and others added 2 commits April 27, 2026 21:53
…lisation, make undefined returns more explicit for builtins)

Co-authored-by: Copilot <copilot@github.com>
…ion appropriately

Co-authored-by: Copilot <copilot@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Iterative processes and proper tail calls

2 participants