Skip to content

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.

3 participants