@@ -8,25 +8,25 @@ multi-staging programming. We can think of compile-time meta-programming as a
8
8
two stage compilation process: one that we write the code in top-level splices,
9
9
that will be used for code generation (macros) and one that will perform all
10
10
necessecary evaluations at compile-time and an object program that we will run
11
- as usual. What if we could synthesize code at runtime and offer one extra stage
12
- to the programmer? Then we can have a value of type ` Expr[T] ` at runtime that we
11
+ as usual. What if we could synthesize code at run-time and offer one extra stage
12
+ to the programmer? Then we can have a value of type ` Expr[T] ` at run-time that we
13
13
can essentially treat as a typed-syntax tree that we can either _ show_ as a
14
14
string (pretty-print) or compile and run. If the number of quotes exceeds the
15
- number of splices more than one (effectively handling at run-time values of type
16
- ` Expr[Expr[T]] ` , ` Expr[Expr[Expr[T]]] ` , ... we talk about Multi-Stage
17
- Programming) .
15
+ number of splices by more than one (effectively handling at run-time values of type
16
+ ` Expr[Expr[T]] ` , ` Expr[Expr[Expr[T]]] ` , ...) then we talk about Multi-Stage
17
+ Programming.
18
18
19
19
The motivation behind this _ paradigm_ is to let runtime information affect or
20
20
guide code-generation.
21
21
22
22
Intuition: The phase in which code is run is determined by the difference
23
23
between the number of splice scopes and quote scopes in which it is embedded.
24
24
25
- - If there are more splices than quotes, the code is run at " compile-time" i.e.
25
+ - If there are more splices than quotes, the code is run at compile-time i.e.
26
26
as a macro. In the general case, this means running an interpreter that
27
27
evaluates the code, which is represented as a typed abstract syntax tree. The
28
28
interpreter can fall back to reflective calls when evaluating an application
29
- of a previously compiled method. If the splice excess is more than one, it
29
+ of a previously compiled method. If the splice excess is more than one, it
30
30
would mean that a macro’s implementation code (as opposed to the code it
31
31
expands to) invokes other macros. If macros are realized by interpretation,
32
32
this would lead to towers of interpreters, where the first interpreter would
@@ -61,7 +61,7 @@ to be executed at a later stage. To run that code, there is another method
61
61
in class ` Expr ` called ` run ` . Note that ` $ ` and ` run ` both map from ` Expr[T] `
62
62
to ` T ` but only ` $ ` is subject to the PCP, whereas ` run ` is just a normal method.
63
63
Run provides a ` QuoteContext ` that can be used to show the expression in the scope of ` run ` .
64
- On the other hand ` withQuoteContext ` provides a ` QuoteContext ` without evauating the expression.
64
+ On the other hand ` withQuoteContext ` provides a ` QuoteContext ` without evaluating the expression.
65
65
66
66
``` scala
67
67
package scala .quoted .staging
0 commit comments