You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basically tools to inspect a continuation. This includes:
Local variables
Result
Bootstrap
And more...
This should allow users to look into the insides of a continuation and produce procs that can allow forking (by copying all locals and construct a new continuation), etc.
One of the benefits for CPS is that we can stop producing helpers like () and instead use a generic implementation like:
template`()`[T: Continuation](c: T): untyped=when c.hasResult:
if c.finished:
c.getResult
else:
trampoline c
else:
trampoline c
Which would allow us to not care about the scope of which a CPS procedure resides in, opening the possibilities for cps generics, like this for example:
# instantiated body for T = intprocfoo[T](x: T): T {.cpsProc.} =
{.cpsEnv: EnvType.}:
typeEnvType {.cpsBooty: booty.} =refobjectofContinuation
x_0* {.cpsLocal.}: int
result_0* {.cpsResult.}: intprocleg0(c: Continuation): Continuation {.nimcall, cpsLeg: EnvType.} =...procleg1(c: Continuation): Continuation {.nimcall, cpsLeg: EnvType.} =...procbooty(x: int): EnvType {.nimcall, cpsBooty.} =...# Default impltramp(booty(x)).getResult
procbar(x: int) {.cps: Continuation.} =echofoo(x)
# Which becomes something like:
c.tmp =whelpfoo(x) # => booty(x)
c.fn = next
c.tmp.mom = thisContinuation
return c.tmp
procnext(c: Continuation): Continuation=let :tmp = c.tmp.getResult
echo :tmp
# Of which there is no dependency on `foo` inner scopes except for the initial# `foo()` symbol
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Basically tools to inspect a continuation. This includes:
This should allow users to look into the insides of a continuation and produce procs that can allow forking (by copying all locals and construct a new continuation), etc.
One of the benefits for CPS is that we can stop producing helpers like
()
and instead use a generic implementation like:Which would allow us to not care about the scope of which a CPS procedure resides in, opening the possibilities for cps generics, like this for example:
Beta Was this translation helpful? Give feedback.
All reactions