Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multistage programming #618

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Multistage programming #618

wants to merge 5 commits into from

Conversation

kehemo
Copy link
Collaborator

@kehemo kehemo commented Apr 17, 2024

No description provided.

@kehemo kehemo marked this pull request as draft April 17, 2024 05:34
@kehemo
Copy link
Collaborator Author

kehemo commented Apr 17, 2024

Python is the metalanguage and the Exo base language has not been changed in any breaking way

Python unquote blocks are evaluated using exec. Each unquote behaves like a new scope in python. Both unquote and quote blocks have parent scopes that look at the nearest enclosing block of the same type. For example:

@proc
def foo():
    a: i8
    with unquote:
        b = 1
        with quote:
            a = 1
            with unquote:
                print(b)

When this procedure is evaluated, it will print "1", and then result in a procedure that is equivalent to:

@proc
def foo():
    a: i8
    a = 1

@codecov-commenter
Copy link

codecov-commenter commented Apr 17, 2024

Codecov Report

Attention: Patch coverage is 95.95960% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 87.06%. Comparing base (56015c3) to head (52e7e57).
Report is 15 commits behind head on main.

Current head 52e7e57 differs from pull request most recent head 571006e

Please upload reports for the commit 571006e to get more accurate results.

Files Patch % Lines
src/exo/pyparser.py 94.77% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #618      +/-   ##
==========================================
+ Coverage   87.00%   87.06%   +0.06%     
==========================================
  Files          94       95       +1     
  Lines       21816    21962     +146     
==========================================
+ Hits        18980    19122     +142     
- Misses       2836     2840       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kehemo
Copy link
Collaborator Author

kehemo commented Apr 17, 2024

Some relatively minor things are still broken:

  • I make the assumption that free variables in Python cannot be mutated. This is not true in the full semantics of Python due to the nonlocal keyword.
  • I do not check the AST when mangling some identifiers that I splice into the code. I only check variables from enclosing scope in that case
  • I allow users to write return statements inside unquote blocks, which kinda doesn't make sense

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.

None yet

2 participants