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

experimental cps detection via scope injection #316

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alaviss
Copy link
Contributor

@alaviss alaviss commented Feb 10, 2024

This employs the use of a "phantom" scope to inject new symbols into the body of a cps block before they are semantically checked.

After that, we surgically extract the transformed output, lifting the result from the phantom scope to the invocation scope.

The experiment currently injects a single symbol: isInCps, which would allow macros/template to detect if they are in cps scope.

This stuff doesn't build yet, a simple:

proc foo() {.cps: Continuation.} = discard

fails with:

cps/cps.nim(245, 41) Error: inconsistent typing for reintroduced symbol 'continuation': previous type was: cps:foo() env; new type is: cps:foo() env

on NimSkull.

This employs the use of a "phantom" scope to inject new symbols into the
body of a cps block before they are semantically checked.

After that, we surgically extract the transformed output, lifting the
result from the phantom scope to the invocation scope.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants