7.2 Phases
(require rebellion/module/phase) | package: rebellion |
"One program’s run-time is another program’s compile-time."
procedure
level : (or/c exact-integer? #f)
> (phase 0) (execution-phase 0)
> (phase 1) (execution-phase 1)
> (phase -1) (execution-phase -1)
> (phase #f) #<label-phase>
procedure
(phase-level ph) → (or/c exact-integer? #f)
ph : phase?
> (phase-level runtime-phase) 0
> (phase-level compile-phase) 1
> (phase-level template-phase) -1
> (phase-level meta-compile-phase) 2
> (phase-level label-phase) #f
procedure
(phase-shift ph relative-levels) → phase?
ph : phase? relative-levels : exact-integer?
> (phase-shift runtime-phase 1) (execution-phase 1)
> (phase-shift meta-compile-phase -2) (execution-phase 0)
> (phase-shift label-phase 5) #<label-phase>
7.2.1 Execution Phases
procedure
(execution-phase? v) → boolean?
v : any/c
procedure
(execution-phase level) → execution-phase?
level : exact-integer?
procedure
ph : execution-phase?
procedure
(execution-phase-shift ph relative-levels) → exact-integer?
ph : execution-phase? relative-levels : exact-integer?
> (execution-phase-shift runtime-phase 2) (execution-phase 2)
> (execution-phase-shift label-phase 5) execution-phase-shift: contract violation
expected: execution-phase?
given: #<label-phase>
in: the 1st argument of
(->
execution-phase?
exact-integer?
execution-phase?)
contract from:
<pkgs>/rebellion/private/phase.rkt
blaming: top-level
(assuming the contract is correct)
at: <pkgs>/rebellion/private/phase.rkt:16.3
value
runtime-phase : phase? = (phase 0)
value
compile-phase : phase? = (phase 1)
procedure
ph : execution-phase?
> (compile-phase-for runtime-phase) (execution-phase 1)
> (compile-phase-for compile-phase) (execution-phase 2)
> (compile-phase-for template-phase) (execution-phase 0)
value
template-phase : phase? = (phase -1)
procedure
ph : execution-phase?
> (template-phase-for runtime-phase) (execution-phase -1)
> (template-phase-for compile-phase) (execution-phase 0)
> (template-phase-for meta-compile-phase) (execution-phase 1)
value
meta-compile-phase : phase? = (phase 2)
7.2.2 The Label Phase
procedure
(label-phase? v) → boolean?
v : any/c
value
label-phase : phase? = (phase #f)