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
2.[Macros](./macros.html) Macros are built on two well-known fundamental
22
-
operations: quotation and splicing. Quotation is expressed as `'{...}` for
23
-
expressions (both forms are equivalent) and as `'[...]` for types. Splicing
24
-
is expressed as `${ ... }`. Whereas inlining is driven completely by the
25
-
language level features of scala (pattern matching, inline vals and
26
-
definitions), macros enable is synthesize/compute code at will treating code
27
-
values as first class citizens and splicing them together independently.
28
-
Here, we move towards _domain-specific_ metaprogramming.
29
-
30
-
3.[Staging](./staging.html) Macros can be seen as distinct phase while
31
-
programming. You write your regular code that will be compiled according to
32
-
the semantics of the language and the macro code that is going to be
33
-
"compiled" or "generated" according the intented purpose of the programmer.
34
-
Staging (or Multi-Stage Programming) can be seen as taking one step further
35
-
this exact concept and can make code generation depent not only on static
36
-
data but also on data available at _runtime_. This splits the evaluation of
37
-
the program in many phases or ... stages, thus the "Multi-Stage" in the
38
-
programming paradigm we say it supports.
39
-
40
-
4.[TASTy Reflection](./tasty-reflect.html) With TASTy reflection we can
41
-
`unseal` fragments of code and analyze them with reflection over the TASTy
42
-
format of the code.
43
-
44
-
5.[TASTy Inspection](./tasty-inspect.html) Up until now we described how we can
45
-
expand, calculate at compile-time, or generate programs. The Scala compiler
46
-
offers quarantees at the level of types that the generated programs cannot go
47
-
wrong. With TASTy inspection we can load compiled files and analyze their
48
-
typed AST structure according to the TASTy format.
49
-
22
+
operations: quotation and splicing. Quotation converts program code to
23
+
data, specifically, a (tree-like) representation of this code. It is
24
+
expressed as `'{...}` for expressions and as `'[...]` for types. Splicing,
25
+
expressed as `${ ... }`, goes the other way: it converts a program's representation
26
+
to program code. Together with `inline`, these two abstractions allow
27
+
to construct program code programmatically.
28
+
29
+
3.[Staging](./staging.html) Where macros construct code at _compile-time_,
30
+
staging lets programs construct new code at _runtime_. That way,
31
+
code generation can depend not only on static data but also on data available at runtime. This splits the evaluation of the program in two or more phases or ...
32
+
stages. Consequently, this method generative programming is called "Multi-Stage Programming". Staging is built on the same foundations as macros. It uses
33
+
quotes and splices, but leaves out `inline`.
34
+
35
+
4.[TASTy Reflection](./tasty-reflect.html) Quotations are a "black-box"
36
+
representation of code. They can be parameterized and composed using
37
+
splices but their structure cannot be analyzed from the outside. Tasty
38
+
reflection gives a way to analyze code structure by partly revealing the representation type of a piece of code in a standard API. The representation
39
+
type is a form of typed abstract syntax tree, which gives rise to the "TASTy`
40
+
moniker.
41
+
42
+
5.[TASTy Inspection](./tasty-inspect.html) Typed abstract syntax trees are serialized
43
+
in a custom compressed binary format in `.tasty` files. TASTy inspection allows
44
+
to load these files and analyze their content's tree structure.
0 commit comments